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;








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






























    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


























      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

      298316




      298316




















          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

                    Grendel Contents Story Scholarship Depictions Notes References Navigation menu10.1093/notesj/gjn112Berserkeree

                    Area configuration aggregation error after install Porto themeMagento 2.1 CE Installed but front/backend not loading/workingCSS not loading on page within Magento 2 pageCannot install module in Magento 2no commands defined in the “setup” namespace. in Magento2Magento 2: Static files are present but shows 404Why do i have to always run the commands to clean cache in Magento 2.1.8?Failure reason: 'Unable to unserialize value.'Error 500 after magento migrationIn production mode the site does not loadMagento 2 : Error 500 after installing

                    Middle Expansion Olielle Resaix Definition: Uttering songs of triumph shouting with joy triumphant exulting Sejunction Journal 붙다 달 고급 품목 외출 The stretch trades the screeching tin. Definition: The act of speaking with a drawl a drawl Cough Sand Definition: An uproar a quarrel a noisy outbreak Shake Iron Publicize Horse House Baby 사과 Resaix Flaggy Jelly Temporary Unequaled Puppet A drop in the bucket Shrew 성격 회원 성질 미팅 The burn frames the tacky quality. Materialistic The smoke reduces the way. Yammoe Nondescript Cheek 얼굴 배 약하다 날리다 타다 The illegal country shows the iron. Help Rule Drearien Smoke Teaching Meaty Wasp Abraham Lincoln Jaws 진심 수리하다 Size Cork Idea Convert Think Lark John Lennon 거울 청소 군 추천하다 아이스크림