Save all products through php/shell script Planned maintenance scheduled April 23, 2019 at 23:30UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?Programmatically trigger admin save action on productRemoving all Related ProductsCreate invoice and shipment in magento via cron based on store view and order ageMagento programmatically force all products to saveCreate categories through installerImport csv file through a shell scriptHow to create/update bulk of products at a time programmaticallyadd to cart products with max qty of products error with run scriptNeed to save all simple products via admin or programaticallyShell script slows down to crawl until caches are clearedExport Category name in xml feed Magento 1.9.2
Converted a Scalar function to a TVF function for parallel execution-Still running in Serial mode
What does 丫 mean? 丫是什么意思?
One-one communication
Putting class ranking in CV, but against dept guidelines
Dyck paths with extra diagonals from valleys (Laser construction)
What is Adi Shankara referring to when he says "He has Vajra marks on his feet"?
Did any compiler fully use 80-bit floating point?
How can I prevent/balance waiting and turtling as a response to cooldown mechanics
Customizing QGIS plugins
macOS: Name for app shortcut screen found by pinching with thumb and three fingers
C's equality operator on converted pointers
What does Turing mean by this statement?
How does a spellshard spellbook work?
How much damage would a cupful of neutron star matter do to the Earth?
How to run automated tests after each commit?
What is the difference between a "ranged attack" and a "ranged weapon attack"?
How can I set the aperture on my DSLR when it's attached to a telescope instead of a lens?
Is multiple magic items in one inherently imbalanced?
Would it be easier to apply for a UK visa if there is a host family to sponsor for you in going there?
Why are my pictures showing a dark band on one edge?
Why do early math courses focus on the cross sections of a cone and not on other 3D objects?
A term for a woman complaining about things/begging in a cute/childish way
Why can't I install Tomboy in Ubuntu Mate 19.04?
Flash light on something
Save all products through php/shell script
Planned maintenance scheduled April 23, 2019 at 23:30UTC (7:30pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?Programmatically trigger admin save action on productRemoving all Related ProductsCreate invoice and shipment in magento via cron based on store view and order ageMagento programmatically force all products to saveCreate categories through installerImport csv file through a shell scriptHow to create/update bulk of products at a time programmaticallyadd to cart products with max qty of products error with run scriptNeed to save all simple products via admin or programaticallyShell script slows down to crawl until caches are clearedExport Category name in xml feed Magento 1.9.2
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I'm in the process of cleaning up my existing magento install by moving the DB and using a new install so I can do away with all the unnecessary extensions taking up space.
Everything seems to have been setup fine, however some product attributes are not showing up in the admin, but doing a save brings the values back. However I have over 7000 products and cant save them individually. All the products are simple products.
So I've used this script from this article.
<?php
require 'app/Mage.php';
Mage::app();
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$products = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*');
foreach ($products as $product)
$product->load();
echo 'Product: ' . $product->getId() . ' - ' . $product->getName() . "xA";
$product->setShortDescription('N/A');
$product->save();
?>
But I need to run this script via the browser and if the internet cuts out, I have to start again going over the ones that were already saved.
Instead, how can I convert this to a shell script and run if via SSH?
Also I have one store that doesn't have the same values as the default (all store views) how/where do I specify that the script run for only that store?
Thanks in advance.
magento-1.9 php simple-product shell ssh
bumped to the homepage by Community♦ 6 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I'm in the process of cleaning up my existing magento install by moving the DB and using a new install so I can do away with all the unnecessary extensions taking up space.
Everything seems to have been setup fine, however some product attributes are not showing up in the admin, but doing a save brings the values back. However I have over 7000 products and cant save them individually. All the products are simple products.
So I've used this script from this article.
<?php
require 'app/Mage.php';
Mage::app();
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$products = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*');
foreach ($products as $product)
$product->load();
echo 'Product: ' . $product->getId() . ' - ' . $product->getName() . "xA";
$product->setShortDescription('N/A');
$product->save();
?>
But I need to run this script via the browser and if the internet cuts out, I have to start again going over the ones that were already saved.
Instead, how can I convert this to a shell script and run if via SSH?
Also I have one store that doesn't have the same values as the default (all store views) how/where do I specify that the script run for only that store?
Thanks in advance.
magento-1.9 php simple-product shell ssh
bumped to the homepage by Community♦ 6 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I'm in the process of cleaning up my existing magento install by moving the DB and using a new install so I can do away with all the unnecessary extensions taking up space.
Everything seems to have been setup fine, however some product attributes are not showing up in the admin, but doing a save brings the values back. However I have over 7000 products and cant save them individually. All the products are simple products.
So I've used this script from this article.
<?php
require 'app/Mage.php';
Mage::app();
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$products = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*');
foreach ($products as $product)
$product->load();
echo 'Product: ' . $product->getId() . ' - ' . $product->getName() . "xA";
$product->setShortDescription('N/A');
$product->save();
?>
But I need to run this script via the browser and if the internet cuts out, I have to start again going over the ones that were already saved.
Instead, how can I convert this to a shell script and run if via SSH?
Also I have one store that doesn't have the same values as the default (all store views) how/where do I specify that the script run for only that store?
Thanks in advance.
magento-1.9 php simple-product shell ssh
I'm in the process of cleaning up my existing magento install by moving the DB and using a new install so I can do away with all the unnecessary extensions taking up space.
Everything seems to have been setup fine, however some product attributes are not showing up in the admin, but doing a save brings the values back. However I have over 7000 products and cant save them individually. All the products are simple products.
So I've used this script from this article.
<?php
require 'app/Mage.php';
Mage::app();
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$products = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*');
foreach ($products as $product)
$product->load();
echo 'Product: ' . $product->getId() . ' - ' . $product->getName() . "xA";
$product->setShortDescription('N/A');
$product->save();
?>
But I need to run this script via the browser and if the internet cuts out, I have to start again going over the ones that were already saved.
Instead, how can I convert this to a shell script and run if via SSH?
Also I have one store that doesn't have the same values as the default (all store views) how/where do I specify that the script run for only that store?
Thanks in advance.
magento-1.9 php simple-product shell ssh
magento-1.9 php simple-product shell ssh
edited Apr 13 '17 at 12:55
Community♦
1
1
asked Mar 8 '17 at 16:16
user2240778user2240778
293316
293316
bumped to the homepage by Community♦ 6 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 6 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Working shell script here: run it from shell directory php productupdate.php --stores <id,...>
shell/productupdate.php
<?php
require_once 'abstract.php';
class Your_Shell_Productupdate extends Mage_Shell_Abstract
protected $_stores = array();
public function __construct()
parent::__construct();
set_time_limit(0);
if ($this->getArg('stores'))
$this->_stores = array_merge(
$this->_stores,
array_map(
'trim',
explode(',', $this->getArg('stores'))
)
);
else
$this->_stores = array(Mage_Core_Model_App::ADMIN_STORE_ID);
public function run()
try
printf(
'Selected stores: %s'."n",
'"'.implode('", "', $this->_stores).'"'
);
foreach ($this->_stores as $storeId)
$products = Mage::getModel('catalog/product')->getCollection();
Mage::getSingleton('core/resource_iterator')->walk(
$products->getSelect(),
array(array($this, '_saveShortDescription')),
array('store_id' => $storeId)
);
printf(
'Done processing.'."n"
.'Total processed products count for store %d: %d'."n",
$storeId, $products->getSize()
);
catch (Exception $e)
echo $e->getMessage().'@'.time();
public function _saveShortDescription($args)
Mage::getSingleton('catalog/product_action')->updateAttributes(
array($args['row']['entity_id']),
array('short_description' => 'N/A'),
$args['store_id']
);
public function usageHelp()
return <<<USAGE
Usage: php -f productupdate.php
--stores <ids> Process only these stores (comma-separated)
help This help
USAGE;
$shell = new Your_Shell_Productupdate();
$shell->run();
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f163462%2fsave-all-products-through-php-shell-script%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Working shell script here: run it from shell directory php productupdate.php --stores <id,...>
shell/productupdate.php
<?php
require_once 'abstract.php';
class Your_Shell_Productupdate extends Mage_Shell_Abstract
protected $_stores = array();
public function __construct()
parent::__construct();
set_time_limit(0);
if ($this->getArg('stores'))
$this->_stores = array_merge(
$this->_stores,
array_map(
'trim',
explode(',', $this->getArg('stores'))
)
);
else
$this->_stores = array(Mage_Core_Model_App::ADMIN_STORE_ID);
public function run()
try
printf(
'Selected stores: %s'."n",
'"'.implode('", "', $this->_stores).'"'
);
foreach ($this->_stores as $storeId)
$products = Mage::getModel('catalog/product')->getCollection();
Mage::getSingleton('core/resource_iterator')->walk(
$products->getSelect(),
array(array($this, '_saveShortDescription')),
array('store_id' => $storeId)
);
printf(
'Done processing.'."n"
.'Total processed products count for store %d: %d'."n",
$storeId, $products->getSize()
);
catch (Exception $e)
echo $e->getMessage().'@'.time();
public function _saveShortDescription($args)
Mage::getSingleton('catalog/product_action')->updateAttributes(
array($args['row']['entity_id']),
array('short_description' => 'N/A'),
$args['store_id']
);
public function usageHelp()
return <<<USAGE
Usage: php -f productupdate.php
--stores <ids> Process only these stores (comma-separated)
help This help
USAGE;
$shell = new Your_Shell_Productupdate();
$shell->run();
add a comment |
Working shell script here: run it from shell directory php productupdate.php --stores <id,...>
shell/productupdate.php
<?php
require_once 'abstract.php';
class Your_Shell_Productupdate extends Mage_Shell_Abstract
protected $_stores = array();
public function __construct()
parent::__construct();
set_time_limit(0);
if ($this->getArg('stores'))
$this->_stores = array_merge(
$this->_stores,
array_map(
'trim',
explode(',', $this->getArg('stores'))
)
);
else
$this->_stores = array(Mage_Core_Model_App::ADMIN_STORE_ID);
public function run()
try
printf(
'Selected stores: %s'."n",
'"'.implode('", "', $this->_stores).'"'
);
foreach ($this->_stores as $storeId)
$products = Mage::getModel('catalog/product')->getCollection();
Mage::getSingleton('core/resource_iterator')->walk(
$products->getSelect(),
array(array($this, '_saveShortDescription')),
array('store_id' => $storeId)
);
printf(
'Done processing.'."n"
.'Total processed products count for store %d: %d'."n",
$storeId, $products->getSize()
);
catch (Exception $e)
echo $e->getMessage().'@'.time();
public function _saveShortDescription($args)
Mage::getSingleton('catalog/product_action')->updateAttributes(
array($args['row']['entity_id']),
array('short_description' => 'N/A'),
$args['store_id']
);
public function usageHelp()
return <<<USAGE
Usage: php -f productupdate.php
--stores <ids> Process only these stores (comma-separated)
help This help
USAGE;
$shell = new Your_Shell_Productupdate();
$shell->run();
add a comment |
Working shell script here: run it from shell directory php productupdate.php --stores <id,...>
shell/productupdate.php
<?php
require_once 'abstract.php';
class Your_Shell_Productupdate extends Mage_Shell_Abstract
protected $_stores = array();
public function __construct()
parent::__construct();
set_time_limit(0);
if ($this->getArg('stores'))
$this->_stores = array_merge(
$this->_stores,
array_map(
'trim',
explode(',', $this->getArg('stores'))
)
);
else
$this->_stores = array(Mage_Core_Model_App::ADMIN_STORE_ID);
public function run()
try
printf(
'Selected stores: %s'."n",
'"'.implode('", "', $this->_stores).'"'
);
foreach ($this->_stores as $storeId)
$products = Mage::getModel('catalog/product')->getCollection();
Mage::getSingleton('core/resource_iterator')->walk(
$products->getSelect(),
array(array($this, '_saveShortDescription')),
array('store_id' => $storeId)
);
printf(
'Done processing.'."n"
.'Total processed products count for store %d: %d'."n",
$storeId, $products->getSize()
);
catch (Exception $e)
echo $e->getMessage().'@'.time();
public function _saveShortDescription($args)
Mage::getSingleton('catalog/product_action')->updateAttributes(
array($args['row']['entity_id']),
array('short_description' => 'N/A'),
$args['store_id']
);
public function usageHelp()
return <<<USAGE
Usage: php -f productupdate.php
--stores <ids> Process only these stores (comma-separated)
help This help
USAGE;
$shell = new Your_Shell_Productupdate();
$shell->run();
Working shell script here: run it from shell directory php productupdate.php --stores <id,...>
shell/productupdate.php
<?php
require_once 'abstract.php';
class Your_Shell_Productupdate extends Mage_Shell_Abstract
protected $_stores = array();
public function __construct()
parent::__construct();
set_time_limit(0);
if ($this->getArg('stores'))
$this->_stores = array_merge(
$this->_stores,
array_map(
'trim',
explode(',', $this->getArg('stores'))
)
);
else
$this->_stores = array(Mage_Core_Model_App::ADMIN_STORE_ID);
public function run()
try
printf(
'Selected stores: %s'."n",
'"'.implode('", "', $this->_stores).'"'
);
foreach ($this->_stores as $storeId)
$products = Mage::getModel('catalog/product')->getCollection();
Mage::getSingleton('core/resource_iterator')->walk(
$products->getSelect(),
array(array($this, '_saveShortDescription')),
array('store_id' => $storeId)
);
printf(
'Done processing.'."n"
.'Total processed products count for store %d: %d'."n",
$storeId, $products->getSize()
);
catch (Exception $e)
echo $e->getMessage().'@'.time();
public function _saveShortDescription($args)
Mage::getSingleton('catalog/product_action')->updateAttributes(
array($args['row']['entity_id']),
array('short_description' => 'N/A'),
$args['store_id']
);
public function usageHelp()
return <<<USAGE
Usage: php -f productupdate.php
--stores <ids> Process only these stores (comma-separated)
help This help
USAGE;
$shell = new Your_Shell_Productupdate();
$shell->run();
edited Apr 17 '18 at 17:53
answered May 24 '17 at 11:25
sv3nsv3n
10k62557
10k62557
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f163462%2fsave-all-products-through-php-shell-script%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown