Question

We have a Multiple website Magento 2 setup, We add product data in All store view and only change product price in individual store views.

Now the problem is when we switch to store view, we have to check the Use Default value checkbox for all attributes. we want this check box to be checked by default. check attached image.

Product page image on admin panal

Was it helpful?

Solution

If you want all products have checked Use Default value then run below sql in database:

DELETE FROM `catalog_product_entity_text` where store_id = 1;
DELETE FROM `catalog_product_entity_datetime` where store_id = 1;
DELETE FROM `catalog_product_entity_decimal` where store_id = 1;
DELETE FROM `catalog_product_entity_int` where store_id = 1;
DELETE FROM `catalog_product_entity_varchar` where store_id = 1;

In example code store ID 1 is ID of store. You need to check ID's of all store-views in admin and run the above code for each store-views.

PS: Make sure you take backup of database before sql query.

OTHER TIPS

For categories i ran the following query and it worked.

DELETE FROM `catalog_category_entity_text` where store_id = 1;
DELETE FROM `catalog_category_entity_datetime` where store_id = 1;
DELETE FROM `catalog_category_entity_decimal` where store_id = 1;
DELETE FROM `catalog_category_entity_int` where store_id = 1;
DELETE FROM `catalog_category_entity_varchar` where store_id = 1;

You can fix it by overriding method copyToStores from class Magento\Catalog\Controller\Adminhtml\Product\Save

Method should be look like below

protected function copyToStores($data, $productId)
{
   return;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top