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;








2















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.



  1. Instead, how can I convert this to a shell script and run if via SSH?


  2. 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.










share|improve this question
















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.





















    2















    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.



    1. Instead, how can I convert this to a shell script and run if via SSH?


    2. 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.










    share|improve this question
















    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.

















      2












      2








      2


      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.



      1. Instead, how can I convert this to a shell script and run if via SSH?


      2. 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.










      share|improve this question
















      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.



      1. Instead, how can I convert this to a shell script and run if via SSH?


      2. 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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      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.






















          1 Answer
          1






          active

          oldest

          votes


















          0














          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();





          share|improve this answer

























            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
            );



            );













            draft saved

            draft discarded


















            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









            0














            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();





            share|improve this answer





























              0














              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();





              share|improve this answer



























                0












                0








                0







                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();





                share|improve this answer















                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();






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Apr 17 '18 at 17:53

























                answered May 24 '17 at 11:25









                sv3nsv3n

                10k62557




                10k62557



























                    draft saved

                    draft discarded
















































                    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.




                    draft saved


                    draft discarded














                    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





















































                    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







                    Popular posts from this blog

                    Magento 2 duplicate PHPSESSID cookie when using session_start() in custom php scriptMagento 2: User cant logged in into to account page, no error showing!Magento duplicate on subdomainGrabbing storeview from cookie (after using language selector)How do I run php custom script on magento2Magento 2: Include PHP script in headerSession lock after using Cm_RedisSessionscript php to update stockMagento set cookie popupMagento 2 session id cookie - where to find it?How to import Configurable product from csv with custom attributes using php scriptMagento 2 run custom PHP script

                    Can not update quote_id field of “quote_item” table magento 2Magento 2.1 - We can't remove the item. (Shopping Cart doesnt allow us to remove items before becomes empty)Add value for custom quote item attribute using REST apiREST API endpoint v1/carts/cartId/items always returns error messageCorrect way to save entries to databaseHow to remove all associated quote objects of a customer completelyMagento 2 - Save value from custom input field to quote_itemGet quote_item data using quote id and product id filter in Magento 2How to set additional data to quote_item table from controller in Magento 2?What is the purpose of additional_data column in quote_item table in magento2Set Custom Price to Quote item magento2 from controller

                    How to solve knockout JS error in Magento 2 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?(Magento2) knockout.js:3012 Uncaught ReferenceError: Unable to process bindingUnable to process binding Knockout.js magento 2Cannot read property `scopeLabel` of undefined on Product Detail PageCan't get Customer Data on frontend in Magento 2Magento2 Order Summary - unable to process bindingKO templates are not loading in Magento 2.1 applicationgetting knockout js error magento 2Product grid not load -— Unable to process binding Knockout.js magento 2Product form not loaded in magento2Uncaught ReferenceError: Unable to process binding “if: function()return (isShowLegend()) ” magento 2