1
votes

The Magento import / export facility leaves a lot to be desired.

We were recently trying to update all the prices for the wholesale store of a Magento multi-store setup. I tested this previously with one product only, and it worked perfectly.

Retail store has price X and wholesale store had price Y. Both products were displayed correctly in the front end and back end.

I then proceeded to apply the same process for all products updating all the wholesale prices in the CSV leaving everything else intact other than applying wholesale to the store column.

After import, Magento has now decided to wipe every single wholesale store 'Use Default Config' setting which was pretty much everything in every product other than the price. So now, no products are displayed in the wholesale store as none of them have a name, description, tax class, visibility, status (etc etc).

Even if I reimport a CSV exactly as Magento spewed everything out to me at the beginning of the day, it still won't put the store back to how it was. It's built in Import/Export feature has just made a complete hash of the entire system after this has already taken me 3 weeks to sort the product data with umpteen formulas and macro's in Excel.

I'm hoping there is a quick and easy way to reinstate the wholesale store 'use default configs' somewhere? Help greatly appreciated.

Just come across this forum post which is another explanation of the exact problem we've just encountered. It has no answers though but thought it may be a useful take on the same problem.

3
Hi @zigojacko Did you manage to actually fix this issue? I'm having the same problem though the DB update will remove any attributes that have changes (and need to be changed).Jory Hogeveen
Hmm, does this help at all @JoryHogeveen? I have not tested it so cannot vouch for its reliability.zigojacko
Hi @zigojacko A bit late reply but I figured it out within the import tool by setting all parameters that don't have content (and thus are set to default) to false. This will trigger the "use default value" within Magento.Jory Hogeveen

3 Answers

2
votes

The easiest way to clean this up is to use the 'Update Attributes' mass action.

To to Catalog->ManageProducts. Filter if needed. Hit the 'Select All' link in the top left corner of the grid. Drop down Actions to select 'Update Attributes' and hit Submit (top right corner of grid)

At this point you are mass editing all of the products you had selected. In the top left corner select the store view you want to edit.

For every attribute you want to update, checkoff 'Change' then check off the 'Use Config Settings' box.

When you are satisfied with your edits hit the 'Save' button in the top right hand corner.

In Code

You can achieve the same thing using the model 'catalog/product_action' like this.

Mage::getSingleton('catalog/product_action')->updateAttributes($arrayIds, array('attribute_code' => 'Desired Attribute Value'), $storeId);

Where $arrayIds is an array of product Ids. This is significantly faster than iterating over a product collection and saving individual items.

2
votes

Actually managed to fix this using a different method to @Jared Kipe's method although continued to comment on his approach as no doubt it would have been a safer and more practical solution than mine.

Within the MySQL database, I removed all records from the following tables relating to the store_id in question:-

catalog_product_entity_datetime
catalog_product_entity_decimal
catalog_product_entity_gallery
catalog_product_entity_group_price
catalog_product_entity_int
catalog_product_entity_media_gallery
catalog_product_entity_media_gallery_value
catalog_product_entity_text
catalog_product_entity_tier_price
catalog_product_entity_varchar

When dealing with thousands of records like I was, this is far quicker executing the queries to handle this, for example:-

DELETE FROM `db_name`.`catalog_product_entity_*` WHERE `store_id` = 2;

(Where you replace db_name with the name of your database and the * with each of the appended names to the table.

This then ensures that for the store_id '2', all product configuration is reset back to 'Use Default Config'.

I'm keen to receive other answers and test out in order to ensure that the best approach to my original issue is highlighted here for future use. I actually think I encountered a bug in Magento as I can't see how the import process could have possible wiped all product data for multistores based on minimal (if at all) change in the CSV that it exported out. Lesson to be learn that writing a script as @Jared Kipe suggests will likely prove the best method, and maybe import dataflows (which I've just created a custom one to update all wholesale pricing and it has worked flawlessly by the way).

0
votes

You can use core_block_abstract_to_html_before adminhtml event to add the required checkboxes for every attribute in admin mass update form.

Then you would need to use catalog_product_attribute_update_before event to delete the values from the EAV tables for a specific store view, only for those attributes that have the checkbox you injected earlier with core_block_abstract_to_html_before set as checked.

Original answer: https://magento.stackexchange.com/a/45229/16724