Magento 1.5 – Copy Product Data Between Stores

importmagento-1.5product

Due to some changes in website I need to copy product data (name, description, price, etc.) from one store, to another. The setup is simple. There is a product which has some default values and then for each store some changes are applied (usually translated default values). Now, one store must use the same values as another one for all of the products. What's the best way to do that?

Currently I have shell script that gets product collections from both stores (so I can check if product is present in both stores). But I'm a little stuck on the copying part. Do I go through every product in collection of the first store, and go through all of its data with foreach and set this data to product in the 2nd store? There must be a cleaner way for that.

Best Answer

The solution I used in the end was pretty simple. I gathered necessary attribute changes via array_diff_assoc and used the result in Mage::getSingleton('catalog/product_action')->updateAttributes()

EDIT:

The reason I opted out of direct DB query is quite simple, it's unsafe and I don't have much control over it. Using standard magento tools was also out of question since there were some customizations made to products that might result in incorrect data transfer. Checking all of the products to make sure it went well and no attributes are lost is out of the question.

So the solution I chose was shell script that would offer me some flexibility and control over entire process. What I did was really simple. I've gathered product collections for both stores in question. Compared them, logged the products that were not in one of the stores. I iterated through the rest of the products, getting the difference in attributes via array_diff_assoc and passing it to Mage::getSingleton('catalog/product_action')->updateAttributes() along with product_id and store_id

Related Topic