1

I wrote a script for adding products programatically from a CSV. It's working fine. Now I need to update it to do followings,

  1. Check if product is already available (using SKU ) and if not, add new product.
  2. If product is available, then update it with new values from the CSV (not changing the SKU but if there are any changes on name, category or price etc..)

I've successfully implemented the first one. I'm stuck on second.

How can I achieve this? Do I need to read every column for certain item and check whether each values is a match in both magento and CSV? or is there some other way to do so? Please help me.

Reading every column for each item may take very long time. I'm looking for some other option.

I just need to update new values from CSV for products that already imported into magento. (without changing the SKU).

4
  • For your second step review this answer it will be helpful to you magento.stackexchange.com/a/157533/49821 – Dhaval Solanki May 3 '18 at 6:26
  • @Magento2Learner I read it, but I still can't understand what he did. All I want is update existing products only if values on CSV has changes. (Ex: if current name is ABC and csv have new name XYZ, then I need to update that value). Could you please help me if you can? – OCdave May 3 '18 at 6:44
  • Then first do one thing check if product exist with sku "XYZ " if yes then load product and compare value with csv if values are different then update it and save that product. – Dhaval Solanki May 3 '18 at 6:48
  • @Magento2Learner I implemented that checking part, and as I mentioned in my question, Reading every column for each item may take very long time. I'm looking for some other option. . What if I remove the existing product and re-add? or is there any other better option? – OCdave May 3 '18 at 7:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.