Post by Cue4cheap » Sun Mar 16, 2025 12:43 am

I had a thought about OCMods and how it'd be nice to run from the command line a script that you tell it the "code" or "name" of the OCMod and it retrieves the XML.
Before I tackle this does anyone know if this is already out there?
Mike

cue4cheap not cheap quality


Expert Member

Posts

Joined
Fri Sep 20, 2013 4:45 am

Post by JNeuhoff » Sun Mar 16, 2025 12:49 am

Cue4cheap wrote:
Sun Mar 16, 2025 12:43 am
I had a thought about OCMods and how it'd be nice to run from the command line a script that you tell it the "code" or "name" of the OCMod and it retrieves the XML.
Before I tackle this does anyone know if this is already out there?
Mike
You can use PHPMyAdmin for this, just see the 'oc_modification' DB table. The two relevant columns are 'name' and 'xml'.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member
Online

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by by mona » Sun Mar 16, 2025 1:37 am


DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by Cue4cheap » Sun Mar 16, 2025 4:53 am

by mona wrote:
Sun Mar 16, 2025 1:37 am
Have you seen this?
https://www.opencart.com/index.php?rout ... n_id=22318
Yes I have and use a version like it.
But I was looking for a slight different flavor so I I could use it to get the current version from the commandline.
Mike
P.S. being able to modify the xml is one reason I wanted to download the copy with changes once the kinks were worked out.
Last edited by Cue4cheap on Sun Mar 16, 2025 4:58 am, edited 1 time in total.

cue4cheap not cheap quality


Expert Member

Posts

Joined
Fri Sep 20, 2013 4:45 am

Post by Cue4cheap » Sun Mar 16, 2025 4:55 am

Ok here is my attempt with a BIG disclaimer: I am NOT responsible for anything this does to your system! It works for me and yes I know it could be consider non-secure!

Code: Select all

#!/bin/bash

CURRENT_DIR=$(pwd)

# Prompt user for the db info
read -p "Enter the user: " user
read -p "Enter the password: " password
read -p "Enter the database name: " db

# Database credentials
DB_HOST="localhost"
DB_USER=$user
DB_PASS=$password
DB_NAME=$db

# Output directory for XML file
OUTPUT_DIR="$CURRENT_DIR/ocmodxml_downloads"
mkdir -p "$OUTPUT_DIR"

# Prompt user for the code
read -p "Enter the modification code to download its XML: " CODE

# Check if code is provided
if [ -z "$CODE" ]; then
    echo "Error: No code provided. Exiting."
    exit 1
fi

# Query to get xml for the specific code
QUERY="SELECT xml FROM modification WHERE code = '$CODE';"

# Execute query and save the result
XML_CONTENT=$(mysql -h "$DB_HOST" -u "$DB_USER" -p"$DB_PASS" "$DB_NAME" -N -e "$QUERY")

# Check if anything was returned
if [ -z "$XML_CONTENT" ]; then
    echo "No XML found for code: $CODE"
    exit 1
else
    # Save XML to a file named after the code
    echo -e "$XML_CONTENT" > "$OUTPUT_DIR/${CODE}.xml"
    echo "XML downloaded to $OUTPUT_DIR/${CODE}.xml"
fi

echo "Done!"

Mike

cue4cheap not cheap quality


Expert Member

Posts

Joined
Fri Sep 20, 2013 4:45 am
Who is online

Users browsing this forum: No registered users and 10 guests