Magento set “Links can be purchased separately” to “No” for all downloadable products programmaticallyWhy only HTTP links are supported as source for downloadable products?How can I disable other downloadable products checkboxes?Bulk update products to include new websitesCreate invoice and shipment in magento via cron based on store view and order ageAllow “shipping address” for downloadable products“Please specify the product required option(s).” for downloadable products when adding them to cart programmaticallyMagento 1.9.3.7 Set expiration time/date for downloadable productsWhy can't magento support unicode encoded urls for downloadable links?how to make Links can be purchased separately option uncheck when importing downloadable product in magento2?Export Category name in xml feed Magento 1.9.2

What's the meaning of "Sollensaussagen"?

How exploitable/balanced is this homebrew spell: Spell Permanency?

Could the museum Saturn V's be refitted for one more flight?

Is it inappropriate for a student to attend their mentor's dissertation defense?

Fair gambler's ruin problem intuition

How to install cross-compiler on Ubuntu 18.04?

Why was Sir Cadogan fired?

What does the same-ish mean?

What Exploit Are These User Agents Trying to Use?

How does a dynamic QR code work?

How to compactly explain secondary and tertiary characters without resorting to stereotypes?

Is there an expression that means doing something right before you will need it rather than doing it in case you might need it?

Why were 5.25" floppy drives cheaper than 8"?

Is it possible to create a QR code using text?

Is it possible to map the firing of neurons in the human brain so as to stimulate artificial memories in someone else?

Rotate ASCII Art by 45 Degrees

Does Dispel Magic work on Tiny Hut?

How to find if SQL server backup is encrypted with TDE without restoring the backup

Was the Stack Exchange "Happy April Fools" page fitting with the '90's code?

Knowledge-based authentication using Domain-driven Design in C#

How seriously should I take size and weight limits of hand luggage?

In Bayesian inference, why are some terms dropped from the posterior predictive?

One verb to replace 'be a member of' a club

Should I tell management that I intend to leave due to bad software development practices?



Magento set “Links can be purchased separately” to “No” for all downloadable products programmatically


Why only HTTP links are supported as source for downloadable products?How can I disable other downloadable products checkboxes?Bulk update products to include new websitesCreate invoice and shipment in magento via cron based on store view and order ageAllow “shipping address” for downloadable products“Please specify the product required option(s).” for downloadable products when adding them to cart programmaticallyMagento 1.9.3.7 Set expiration time/date for downloadable productsWhy can't magento support unicode encoded urls for downloadable links?how to make Links can be purchased separately option uncheck when importing downloadable product in magento2?Export Category name in xml feed Magento 1.9.2













1















I am using Magento CE 1.9.2.2 in my site.



How can I set Links can be purchased separately admin setting to No for all downloadable products programmatically.



I have tried following but it doesn't work:



<?php
error_reporting(E_ALL);
require_once './app/Mage.php';
umask(0);
Mage::app('admin');

$productCollection = Mage::getModel('catalog/product')->getCollection()
->addFieldToFilter('type_id', "downloadable");
foreach($productCollection as $product):
$product->setData('links_purchased_separately', false);
$product->save();
endforeach;









share|improve this question
















bumped to the homepage by Community 2 days ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.



















    1















    I am using Magento CE 1.9.2.2 in my site.



    How can I set Links can be purchased separately admin setting to No for all downloadable products programmatically.



    I have tried following but it doesn't work:



    <?php
    error_reporting(E_ALL);
    require_once './app/Mage.php';
    umask(0);
    Mage::app('admin');

    $productCollection = Mage::getModel('catalog/product')->getCollection()
    ->addFieldToFilter('type_id', "downloadable");
    foreach($productCollection as $product):
    $product->setData('links_purchased_separately', false);
    $product->save();
    endforeach;









    share|improve this question
















    bumped to the homepage by Community 2 days ago


    This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.

















      1












      1








      1








      I am using Magento CE 1.9.2.2 in my site.



      How can I set Links can be purchased separately admin setting to No for all downloadable products programmatically.



      I have tried following but it doesn't work:



      <?php
      error_reporting(E_ALL);
      require_once './app/Mage.php';
      umask(0);
      Mage::app('admin');

      $productCollection = Mage::getModel('catalog/product')->getCollection()
      ->addFieldToFilter('type_id', "downloadable");
      foreach($productCollection as $product):
      $product->setData('links_purchased_separately', false);
      $product->save();
      endforeach;









      share|improve this question
















      I am using Magento CE 1.9.2.2 in my site.



      How can I set Links can be purchased separately admin setting to No for all downloadable products programmatically.



      I have tried following but it doesn't work:



      <?php
      error_reporting(E_ALL);
      require_once './app/Mage.php';
      umask(0);
      Mage::app('admin');

      $productCollection = Mage::getModel('catalog/product')->getCollection()
      ->addFieldToFilter('type_id', "downloadable");
      foreach($productCollection as $product):
      $product->setData('links_purchased_separately', false);
      $product->save();
      endforeach;






      magento-1.9 product admin downloadable script






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Feb 8 '16 at 7:11







      Vicky Dev

















      asked Feb 8 '16 at 7:01









      Vicky DevVicky Dev

      1,28261539




      1,28261539





      bumped to the homepage by Community 2 days 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 2 days ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.






















          3 Answers
          3






          active

          oldest

          votes


















          0














          I have used Magmi to achieve this. You have to put sku, links_purchased_separately in header row of import CSV. Then list all SKUs in first column and put 0 in links_purchased_separately column. Upload CSV via dataflow profiles and then run via Magmi.






          share|improve this answer






























            0














            Hope it is not too late for an answer.
            You should use addAttributeToFilter() instead of addFieldToFilter().



            In Magento addAttributeToFilter is using for EAV module (such as products), and addFiledToFilter is using for flat tables.






            share|improve this answer
































              0














              Declare a product collection factory and a product repository in your constructor as follows



               MagentoConfigurableProductModelResourceModelProductTypeConfigurableProductCollectionFactory $productCollectionFactory,
              MagentoCatalogApiProductRepositoryInterface $productRepository

              $this->productCollectionFactory = $productCollectionFactory;
              $this->productRepository = $productRepository;


              Then in your code use it as follows:



              $productCollection = $this->productCollectionFactory->create (); 
              $productCollection->addAttributeToSelect ( '*' );
              $productCollection->addAttributeToFilter ( 'type_id', 'downloadable');


              The product collection will return a collection of products, so you'll need to get the actual products in the collection using the product repository. Try:



              $ids = $productCollection->getAllIds();
              for each ($ids as $oneid)

              $product = $this->productRepository->getById($oneid);
              $product->setCustomAttribute('links_purchased_separately', false);
              $this->productRepository->save($product);



              Instead of using 'setData', set a custom attribute on the product as above.






              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%2f100739%2fmagento-set-links-can-be-purchased-separately-to-no-for-all-downloadable-pro%23new-answer', 'question_page');

                );

                Post as a guest















                Required, but never shown

























                3 Answers
                3






                active

                oldest

                votes








                3 Answers
                3






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes









                0














                I have used Magmi to achieve this. You have to put sku, links_purchased_separately in header row of import CSV. Then list all SKUs in first column and put 0 in links_purchased_separately column. Upload CSV via dataflow profiles and then run via Magmi.






                share|improve this answer



























                  0














                  I have used Magmi to achieve this. You have to put sku, links_purchased_separately in header row of import CSV. Then list all SKUs in first column and put 0 in links_purchased_separately column. Upload CSV via dataflow profiles and then run via Magmi.






                  share|improve this answer

























                    0












                    0








                    0







                    I have used Magmi to achieve this. You have to put sku, links_purchased_separately in header row of import CSV. Then list all SKUs in first column and put 0 in links_purchased_separately column. Upload CSV via dataflow profiles and then run via Magmi.






                    share|improve this answer













                    I have used Magmi to achieve this. You have to put sku, links_purchased_separately in header row of import CSV. Then list all SKUs in first column and put 0 in links_purchased_separately column. Upload CSV via dataflow profiles and then run via Magmi.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Sep 20 '16 at 7:14









                    FarrukhFarrukh

                    1




                    1























                        0














                        Hope it is not too late for an answer.
                        You should use addAttributeToFilter() instead of addFieldToFilter().



                        In Magento addAttributeToFilter is using for EAV module (such as products), and addFiledToFilter is using for flat tables.






                        share|improve this answer





























                          0














                          Hope it is not too late for an answer.
                          You should use addAttributeToFilter() instead of addFieldToFilter().



                          In Magento addAttributeToFilter is using for EAV module (such as products), and addFiledToFilter is using for flat tables.






                          share|improve this answer



























                            0












                            0








                            0







                            Hope it is not too late for an answer.
                            You should use addAttributeToFilter() instead of addFieldToFilter().



                            In Magento addAttributeToFilter is using for EAV module (such as products), and addFiledToFilter is using for flat tables.






                            share|improve this answer















                            Hope it is not too late for an answer.
                            You should use addAttributeToFilter() instead of addFieldToFilter().



                            In Magento addAttributeToFilter is using for EAV module (such as products), and addFiledToFilter is using for flat tables.







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Jan 3 '17 at 15:01









                            Piyush

                            4,82972054




                            4,82972054










                            answered Jan 3 '17 at 14:39









                            yariv_kohnyariv_kohn

                            1




                            1





















                                0














                                Declare a product collection factory and a product repository in your constructor as follows



                                 MagentoConfigurableProductModelResourceModelProductTypeConfigurableProductCollectionFactory $productCollectionFactory,
                                MagentoCatalogApiProductRepositoryInterface $productRepository

                                $this->productCollectionFactory = $productCollectionFactory;
                                $this->productRepository = $productRepository;


                                Then in your code use it as follows:



                                $productCollection = $this->productCollectionFactory->create (); 
                                $productCollection->addAttributeToSelect ( '*' );
                                $productCollection->addAttributeToFilter ( 'type_id', 'downloadable');


                                The product collection will return a collection of products, so you'll need to get the actual products in the collection using the product repository. Try:



                                $ids = $productCollection->getAllIds();
                                for each ($ids as $oneid)

                                $product = $this->productRepository->getById($oneid);
                                $product->setCustomAttribute('links_purchased_separately', false);
                                $this->productRepository->save($product);



                                Instead of using 'setData', set a custom attribute on the product as above.






                                share|improve this answer





























                                  0














                                  Declare a product collection factory and a product repository in your constructor as follows



                                   MagentoConfigurableProductModelResourceModelProductTypeConfigurableProductCollectionFactory $productCollectionFactory,
                                  MagentoCatalogApiProductRepositoryInterface $productRepository

                                  $this->productCollectionFactory = $productCollectionFactory;
                                  $this->productRepository = $productRepository;


                                  Then in your code use it as follows:



                                  $productCollection = $this->productCollectionFactory->create (); 
                                  $productCollection->addAttributeToSelect ( '*' );
                                  $productCollection->addAttributeToFilter ( 'type_id', 'downloadable');


                                  The product collection will return a collection of products, so you'll need to get the actual products in the collection using the product repository. Try:



                                  $ids = $productCollection->getAllIds();
                                  for each ($ids as $oneid)

                                  $product = $this->productRepository->getById($oneid);
                                  $product->setCustomAttribute('links_purchased_separately', false);
                                  $this->productRepository->save($product);



                                  Instead of using 'setData', set a custom attribute on the product as above.






                                  share|improve this answer



























                                    0












                                    0








                                    0







                                    Declare a product collection factory and a product repository in your constructor as follows



                                     MagentoConfigurableProductModelResourceModelProductTypeConfigurableProductCollectionFactory $productCollectionFactory,
                                    MagentoCatalogApiProductRepositoryInterface $productRepository

                                    $this->productCollectionFactory = $productCollectionFactory;
                                    $this->productRepository = $productRepository;


                                    Then in your code use it as follows:



                                    $productCollection = $this->productCollectionFactory->create (); 
                                    $productCollection->addAttributeToSelect ( '*' );
                                    $productCollection->addAttributeToFilter ( 'type_id', 'downloadable');


                                    The product collection will return a collection of products, so you'll need to get the actual products in the collection using the product repository. Try:



                                    $ids = $productCollection->getAllIds();
                                    for each ($ids as $oneid)

                                    $product = $this->productRepository->getById($oneid);
                                    $product->setCustomAttribute('links_purchased_separately', false);
                                    $this->productRepository->save($product);



                                    Instead of using 'setData', set a custom attribute on the product as above.






                                    share|improve this answer















                                    Declare a product collection factory and a product repository in your constructor as follows



                                     MagentoConfigurableProductModelResourceModelProductTypeConfigurableProductCollectionFactory $productCollectionFactory,
                                    MagentoCatalogApiProductRepositoryInterface $productRepository

                                    $this->productCollectionFactory = $productCollectionFactory;
                                    $this->productRepository = $productRepository;


                                    Then in your code use it as follows:



                                    $productCollection = $this->productCollectionFactory->create (); 
                                    $productCollection->addAttributeToSelect ( '*' );
                                    $productCollection->addAttributeToFilter ( 'type_id', 'downloadable');


                                    The product collection will return a collection of products, so you'll need to get the actual products in the collection using the product repository. Try:



                                    $ids = $productCollection->getAllIds();
                                    for each ($ids as $oneid)

                                    $product = $this->productRepository->getById($oneid);
                                    $product->setCustomAttribute('links_purchased_separately', false);
                                    $this->productRepository->save($product);



                                    Instead of using 'setData', set a custom attribute on the product as above.







                                    share|improve this answer














                                    share|improve this answer



                                    share|improve this answer








                                    edited Jan 5 '17 at 12:22

























                                    answered Jan 5 '17 at 11:55









                                    learmolearmo

                                    11




                                    11



























                                        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%2f100739%2fmagento-set-links-can-be-purchased-separately-to-no-for-all-downloadable-pro%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

                                        Sum ergo cogito? 1 nng

                                        三茅街道4182Guuntc Dn precexpngmageondP