How 'Add Design Change' with magento shell script?
-
13-12-2019 - |
Question
I want add new theme with magento shell script. I think it's possible with direct access to MySQL 'design_change' table. But I don't know how to do it. Any ideas?
Solution
First you need to create theme in file-level
Then using below query for applying the theme into your store
INSERT INTO 'design_change' ('design_change_id', 'store_id', 'design', 'date_from', 'date_to') VALUES ('', 'STORE_ID', 'packageName/ThemeName', 'Starting_date', 'END_Date');
- design_change_id should be blank as it primary key.
- store_id is the store id of your store where you want to apply the the theme.
- packageName is the package of theme which is located at
app/design/{area}/{packageName}
. ThemeName is the name of theme which will be point to the locationapp/design/{area}/{packageName}/{ThemeName}
. Magento skin folder location should beskin/{area}/{packageName}/{ThemeName}
. - date_from is the starting date of applying theme
- date_to end date of applying theme
Shell Script:
If you want do this using shell php script then try below code:
<?PHP
require_once "YOUR_MAGENTO_DIR/app/Mage.php";
umask(0);
Mage::app('admin');
$design = Mage::getModel('core/design');
$design->setData('store_id','STORE_ID');
$design->setData('design','packageName/ThemeName');
$design->setData('date_from','YYYY-MM_DD');
$design->setData('date_to','YYYY-MM_DD');
try {
$design->save();
echo 'The design change has been saved.';
} catch (Exception $e){
$e->getMessage();
}
OTHER TIPS
If by a Shell script you mean, a means to do such via Shell with a boot strapped Magento and not just a raw bash script or such.
Familiarize yourself with:
It is the same scripts that can be executed via php -f shell/file.php -- somearguments
Using Amit's SQL should work or you can utilize the framework with the shell abstract mentioned.