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;
}

If anyone is curious what these SQL Queries are deleting in these tables in the above answers. See below.

4 Tables to Delete From to set back to "Use Default Values".

catalog_product_entity_varchar = Product Name & Meta Title in Upper Limits Scope.

catalog_product_entity_text = Product Description & Meta Description & Meta Keyword.

catalog_product_entity_int = Resets Tax, 360 Image, Visibility to default values.

catalog_product_entity_datetime = Resets Dates back to default value.

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 reset all setting By Default Checked used to Store ID

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;

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top