How to delete product images using magento csv import in magento 2?












3















Magento Version: 2.1.0



We have added the wrong image for some of the products when importing through Magento CSV import. we want to remove the images from those products and add new images or replace the images for the same.



We are trying to import using the normal Magento import functionality by selecting replace option. If we select to delete it will delete the complete product. Same issue we will get if we want to remove any multiselect option and add new for any particular product.



EX: if SKU is xyz456 - we added 3 images before and we want to remove these and add new 3 or 4 images or replace the images for the same SKU then it is not working. It will add new images also and it will keep old images also.



Same way if we have selected multiselect options for attribute lets say material: wood, iron and we want to change it to steel, copper then it is not allowing. It will add Material: wood, iron, steel, copper



Can anyone please explain how we can update these. Magento has not provided clear documentation on product import and export functionality.










share|improve this question
















bumped to the homepage by Community 5 mins ago


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




















    3















    Magento Version: 2.1.0



    We have added the wrong image for some of the products when importing through Magento CSV import. we want to remove the images from those products and add new images or replace the images for the same.



    We are trying to import using the normal Magento import functionality by selecting replace option. If we select to delete it will delete the complete product. Same issue we will get if we want to remove any multiselect option and add new for any particular product.



    EX: if SKU is xyz456 - we added 3 images before and we want to remove these and add new 3 or 4 images or replace the images for the same SKU then it is not working. It will add new images also and it will keep old images also.



    Same way if we have selected multiselect options for attribute lets say material: wood, iron and we want to change it to steel, copper then it is not allowing. It will add Material: wood, iron, steel, copper



    Can anyone please explain how we can update these. Magento has not provided clear documentation on product import and export functionality.










    share|improve this question
















    bumped to the homepage by Community 5 mins ago


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


















      3












      3








      3








      Magento Version: 2.1.0



      We have added the wrong image for some of the products when importing through Magento CSV import. we want to remove the images from those products and add new images or replace the images for the same.



      We are trying to import using the normal Magento import functionality by selecting replace option. If we select to delete it will delete the complete product. Same issue we will get if we want to remove any multiselect option and add new for any particular product.



      EX: if SKU is xyz456 - we added 3 images before and we want to remove these and add new 3 or 4 images or replace the images for the same SKU then it is not working. It will add new images also and it will keep old images also.



      Same way if we have selected multiselect options for attribute lets say material: wood, iron and we want to change it to steel, copper then it is not allowing. It will add Material: wood, iron, steel, copper



      Can anyone please explain how we can update these. Magento has not provided clear documentation on product import and export functionality.










      share|improve this question
















      Magento Version: 2.1.0



      We have added the wrong image for some of the products when importing through Magento CSV import. we want to remove the images from those products and add new images or replace the images for the same.



      We are trying to import using the normal Magento import functionality by selecting replace option. If we select to delete it will delete the complete product. Same issue we will get if we want to remove any multiselect option and add new for any particular product.



      EX: if SKU is xyz456 - we added 3 images before and we want to remove these and add new 3 or 4 images or replace the images for the same SKU then it is not working. It will add new images also and it will keep old images also.



      Same way if we have selected multiselect options for attribute lets say material: wood, iron and we want to change it to steel, copper then it is not allowing. It will add Material: wood, iron, steel, copper



      Can anyone please explain how we can update these. Magento has not provided clear documentation on product import and export functionality.







      magento2 magento-2.1 product-images csv magento2.1.0






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 27 '17 at 6:39









      Prince Patel

      13.3k54676




      13.3k54676










      asked Dec 27 '17 at 6:37









      RahulRahul

      161




      161





      bumped to the homepage by Community 5 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 5 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 Answers
          2






          active

          oldest

          votes


















          0















          Use following code to remove image from product in Magento2.




          // Instance of object manager

          $objectManager = MagentoFrameworkAppObjectManager::getInstance();
          $productId = Your_Product_Id; // Id of product

          $product = $objectManager->create('MagentoCatalogModelProduct')->load($productId);
          $productRepository = $objectManager->create('MagentoCatalogApiProductRepositoryInterface');
          $existingMediaGalleryEntries = $product->getMediaGalleryEntries();
          foreach ($existingMediaGalleryEntries as $key => $entry) {
          unset($existingMediaGalleryEntries[$key]);
          }
          $product->setMediaGalleryEntries($existingMediaGalleryEntries);
          $productRepository->save($product);





          share|improve this answer
























          • We want to remove or replace the image using magento csv import how we can do this..? Can you please explain....Do we need to write any code for this..? We want to do all product updates, addition, remove etc.... using csv import.

            – Rahul
            Dec 28 '17 at 6:36











          • magento 2.2.6 this doesnt work.

            – TTech IT Solutions
            Sep 20 '18 at 14:48



















          -1














          You can do it by Following the steps in ,



          http://docs.magento.com/m1/ce/user_guide/store-operations/dataflow.html






          share|improve this answer













          We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.















          • Aravind, you have recently gone through a few questions and just posted links to documentation. That's not helpful.

            – benmarks
            Dec 27 '17 at 13:28











          • This is for magento 1 ..... you cannot remove product image. If we select delete while importing it deletes complete product.

            – Rahul
            Dec 28 '17 at 6:38











          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%2f207226%2fhow-to-delete-product-images-using-magento-csv-import-in-magento-2%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0















          Use following code to remove image from product in Magento2.




          // Instance of object manager

          $objectManager = MagentoFrameworkAppObjectManager::getInstance();
          $productId = Your_Product_Id; // Id of product

          $product = $objectManager->create('MagentoCatalogModelProduct')->load($productId);
          $productRepository = $objectManager->create('MagentoCatalogApiProductRepositoryInterface');
          $existingMediaGalleryEntries = $product->getMediaGalleryEntries();
          foreach ($existingMediaGalleryEntries as $key => $entry) {
          unset($existingMediaGalleryEntries[$key]);
          }
          $product->setMediaGalleryEntries($existingMediaGalleryEntries);
          $productRepository->save($product);





          share|improve this answer
























          • We want to remove or replace the image using magento csv import how we can do this..? Can you please explain....Do we need to write any code for this..? We want to do all product updates, addition, remove etc.... using csv import.

            – Rahul
            Dec 28 '17 at 6:36











          • magento 2.2.6 this doesnt work.

            – TTech IT Solutions
            Sep 20 '18 at 14:48
















          0















          Use following code to remove image from product in Magento2.




          // Instance of object manager

          $objectManager = MagentoFrameworkAppObjectManager::getInstance();
          $productId = Your_Product_Id; // Id of product

          $product = $objectManager->create('MagentoCatalogModelProduct')->load($productId);
          $productRepository = $objectManager->create('MagentoCatalogApiProductRepositoryInterface');
          $existingMediaGalleryEntries = $product->getMediaGalleryEntries();
          foreach ($existingMediaGalleryEntries as $key => $entry) {
          unset($existingMediaGalleryEntries[$key]);
          }
          $product->setMediaGalleryEntries($existingMediaGalleryEntries);
          $productRepository->save($product);





          share|improve this answer
























          • We want to remove or replace the image using magento csv import how we can do this..? Can you please explain....Do we need to write any code for this..? We want to do all product updates, addition, remove etc.... using csv import.

            – Rahul
            Dec 28 '17 at 6:36











          • magento 2.2.6 this doesnt work.

            – TTech IT Solutions
            Sep 20 '18 at 14:48














          0












          0








          0








          Use following code to remove image from product in Magento2.




          // Instance of object manager

          $objectManager = MagentoFrameworkAppObjectManager::getInstance();
          $productId = Your_Product_Id; // Id of product

          $product = $objectManager->create('MagentoCatalogModelProduct')->load($productId);
          $productRepository = $objectManager->create('MagentoCatalogApiProductRepositoryInterface');
          $existingMediaGalleryEntries = $product->getMediaGalleryEntries();
          foreach ($existingMediaGalleryEntries as $key => $entry) {
          unset($existingMediaGalleryEntries[$key]);
          }
          $product->setMediaGalleryEntries($existingMediaGalleryEntries);
          $productRepository->save($product);





          share|improve this answer














          Use following code to remove image from product in Magento2.




          // Instance of object manager

          $objectManager = MagentoFrameworkAppObjectManager::getInstance();
          $productId = Your_Product_Id; // Id of product

          $product = $objectManager->create('MagentoCatalogModelProduct')->load($productId);
          $productRepository = $objectManager->create('MagentoCatalogApiProductRepositoryInterface');
          $existingMediaGalleryEntries = $product->getMediaGalleryEntries();
          foreach ($existingMediaGalleryEntries as $key => $entry) {
          unset($existingMediaGalleryEntries[$key]);
          }
          $product->setMediaGalleryEntries($existingMediaGalleryEntries);
          $productRepository->save($product);






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Dec 27 '17 at 10:57









          Chander ShekharChander Shekhar

          536315




          536315













          • We want to remove or replace the image using magento csv import how we can do this..? Can you please explain....Do we need to write any code for this..? We want to do all product updates, addition, remove etc.... using csv import.

            – Rahul
            Dec 28 '17 at 6:36











          • magento 2.2.6 this doesnt work.

            – TTech IT Solutions
            Sep 20 '18 at 14:48



















          • We want to remove or replace the image using magento csv import how we can do this..? Can you please explain....Do we need to write any code for this..? We want to do all product updates, addition, remove etc.... using csv import.

            – Rahul
            Dec 28 '17 at 6:36











          • magento 2.2.6 this doesnt work.

            – TTech IT Solutions
            Sep 20 '18 at 14:48

















          We want to remove or replace the image using magento csv import how we can do this..? Can you please explain....Do we need to write any code for this..? We want to do all product updates, addition, remove etc.... using csv import.

          – Rahul
          Dec 28 '17 at 6:36





          We want to remove or replace the image using magento csv import how we can do this..? Can you please explain....Do we need to write any code for this..? We want to do all product updates, addition, remove etc.... using csv import.

          – Rahul
          Dec 28 '17 at 6:36













          magento 2.2.6 this doesnt work.

          – TTech IT Solutions
          Sep 20 '18 at 14:48





          magento 2.2.6 this doesnt work.

          – TTech IT Solutions
          Sep 20 '18 at 14:48













          -1














          You can do it by Following the steps in ,



          http://docs.magento.com/m1/ce/user_guide/store-operations/dataflow.html






          share|improve this answer













          We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.















          • Aravind, you have recently gone through a few questions and just posted links to documentation. That's not helpful.

            – benmarks
            Dec 27 '17 at 13:28











          • This is for magento 1 ..... you cannot remove product image. If we select delete while importing it deletes complete product.

            – Rahul
            Dec 28 '17 at 6:38
















          -1














          You can do it by Following the steps in ,



          http://docs.magento.com/m1/ce/user_guide/store-operations/dataflow.html






          share|improve this answer













          We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.















          • Aravind, you have recently gone through a few questions and just posted links to documentation. That's not helpful.

            – benmarks
            Dec 27 '17 at 13:28











          • This is for magento 1 ..... you cannot remove product image. If we select delete while importing it deletes complete product.

            – Rahul
            Dec 28 '17 at 6:38














          -1












          -1








          -1







          You can do it by Following the steps in ,



          http://docs.magento.com/m1/ce/user_guide/store-operations/dataflow.html






          share|improve this answer













          You can do it by Following the steps in ,



          http://docs.magento.com/m1/ce/user_guide/store-operations/dataflow.html







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Dec 27 '17 at 9:21









          aravindaravind

          310113




          310113



          We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.




          We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.














          • Aravind, you have recently gone through a few questions and just posted links to documentation. That's not helpful.

            – benmarks
            Dec 27 '17 at 13:28











          • This is for magento 1 ..... you cannot remove product image. If we select delete while importing it deletes complete product.

            – Rahul
            Dec 28 '17 at 6:38



















          • Aravind, you have recently gone through a few questions and just posted links to documentation. That's not helpful.

            – benmarks
            Dec 27 '17 at 13:28











          • This is for magento 1 ..... you cannot remove product image. If we select delete while importing it deletes complete product.

            – Rahul
            Dec 28 '17 at 6:38

















          Aravind, you have recently gone through a few questions and just posted links to documentation. That's not helpful.

          – benmarks
          Dec 27 '17 at 13:28





          Aravind, you have recently gone through a few questions and just posted links to documentation. That's not helpful.

          – benmarks
          Dec 27 '17 at 13:28













          This is for magento 1 ..... you cannot remove product image. If we select delete while importing it deletes complete product.

          – Rahul
          Dec 28 '17 at 6:38





          This is for magento 1 ..... you cannot remove product image. If we select delete while importing it deletes complete product.

          – Rahul
          Dec 28 '17 at 6:38


















          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%2f207226%2fhow-to-delete-product-images-using-magento-csv-import-in-magento-2%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

          Alcázar de San Juan

          Griza ansero

          Heinkel He 51