2

Something wrong happens with my store view management since I've created a new store view.

Basically, till now all the boxes for all views "use default value" were selected but recently most of all have been randomly unselected. That means, when I want to update an information about a product (Price or status for example) I need to check for each store view if the box "use Default value" is selected. ( http://prntscr.com/ekyw7b )

Does anybody know if there is a way to automatically select the box "use default value" for all product information (except Name & Description) and all store view ?

Another good solution would be to define all product information (except Name & Description) as [Global] instead of [Website] or [Store View] ...

Can anybody help to figure out how to proceed ?

3 Answers 3

2

I have quick solution for this. but make sure you backup database before using this solution.

You can run below sql so all checkbox will be clicked as use default expect product and description won't be clicked.

DELETE FROM `catalog_product_entity_text` where store_id = 0 AND NOT attribute_id=71 AND NOT attribute_id=72;
DELETE FROM `catalog_product_entity_datetime` where store_id = 0 AND NOT attribute_id=71 AND NOT attribute_id=72;
DELETE FROM `catalog_product_entity_decimal` where store_id = 0 AND NOT attribute_id=71 AND NOT attribute_id=72; 
DELETE FROM `catalog_product_entity_int` where store_id = 0 AND NOT attribute_id=71 AND NOT attribute_id=72;
DELETE FROM `catalog_product_entity_varchar` where store_id = 0 AND NOT attribute_id=71 AND NOT attribute_id=72;

Important Note Here I have used store_id=0 instead of zero You need to use store id of your website. You need to run below query as more than one time as you have stores. like you have 4 store then you need to run below sql 4 time and you need to change store_id every time.

Also attribute_id = 71 is for product name and attribute_id=72 is for description.

Hope it helps.

Thanks.

1

Create a php file with below content and then run it in your browser.

<?php
require_once 'app/Mage.php';
umask(0);
Mage::app('default');
$productCollection = Mage::getModel('catalog/product')->getCollection()->getColumnValues('entity_id');
$attrArray=array('url_key','name','description'); // Add as many attribute as you want to select default value
$products = $productCollection;
$stores = array(1,2); // Add all your store IDs
$productsAsString = implode(',', $products);
$storesAsString = implode(',', $stores);
$resource = Mage::getSingleton('core/resource');
$connection = $resource->getConnection('core_write');
$eavConfig = Mage::getModel('eav/config');
$tables = array();
foreach ($attrArray as $attributeCode){
    $attribute = $eavConfig->getAttribute('catalog_product', $attributeCode);
    if ($attribute){
        $tableName = $resource->getTableName('catalog/product') . '_' . $attribute->getBackendType();
        $tables[$tableName][] = $attribute->getId();
    }
}
foreach ($tables as $tableName => $attributeIds){
    $attributeIdsAsString = implode(',', $attributeIds);
    $q = "DELETE FROM {$tableName}
                WHERE
                    attribute_id IN ({$attributeIdsAsString}) AND
                    entity_id IN ({$productsAsString}) AND
                    store_id IN ({$storesAsString})";
    $connection->query($q);
}
?>
0

To anyone getting some randomly created store-specific attribute values...

I actually getting in this same situation for a while now without finding out the cause... Supposing someone was using the scope selector... Even if nobody admitted it...

Random bug, hard to find out...

And finally found :

As far as i'm concerned, it was caused to the usage of MDN_EmbededErp + AOE_Scheduler + Amasty_Acart (Abandoned cart emails) AND / OR Amasty_Followup.

Amasty's extensions both uses cron jobs where there changed the current app's store to the order store to produce emails with proper store view scope but dint restore the admin store back.

AOE_Scheduler implies multiple jobs can be run in one single cron.sh execution (and i assume this can also occurs in native core cron schedule, no time to check, always use AOE_Scheduler in my projects...)

As a consequence, MDN_EmbededErp jobs can eventually be running in a store view context instead of the admin one. So loading a product and saving it causes store-view specific values to be saved in database.

Generally speaking, consider finding usages of Mage::app()->setCurrentStore(...) in non-core code and check, in case of cron jobs, the admin store is restored back.

Amasty notified about issue, not sure if they will fix that.

Hope this could help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.