Save all products through php/shell script Planned maintenance scheduled April 23, 2019 at 23:30 UTC (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
/bin/ls sorts differently than just ls
What kind of capacitor is this in the image?
Reflections in a Square
Can gravitational waves pass through a black hole?
Converting a text document with special format to Pandas DataFrame
Should man-made satellites feature an intelligent inverted "cow catcher"?
Short story about an alien named Ushtu(?) coming from a future Earth, when ours was destroyed by a nuclear explosion
Does using the inspiration rules for character defects tend to encourage players to display MGS?
Has a Nobel Peace laureate ever been accused of war crimes?
Can I ask an author to send me his ebook?
Is "ein Herz wie das meine" an antiquated or colloquial use of the possesive pronoun?
What is the ongoing value of the Kanban board to the developers as opposed to management
Would I be safe to drive a 23 year old truck for 7 hours / 450 miles?
Can the van der Waals coefficients be negative in the van der Waals equation for real gases?
Lights are flickering on and off after accidentally bumping into light switch
How to create a command for the "strange m" symbol in latex?
Can 'non' with gerundive mean both lack of obligation and negative obligation?
Like totally amazing interchangeable sister outfit accessory swapping or whatever
Can this water damage be explained by lack of gutters and grading issues?
Does GDPR cover the collection of data by websites that crawl the web and resell user data
Why did Europeans not widely domesticate foxes?
Why aren't these two solutions equivalent? Combinatorics problem
Why these surprising proportionalities of integrals involving odd zeta values?
Is Vivien of the Wilds + Wilderness Reclimation a competitive combo?
Save all products through php/shell script
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (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
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
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
298316
298316
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