15

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

6
  • Did you get the answer for this ?
    – Jarnail S
    Sep 21, 2017 at 7:47
  • @Jai unfortunately no Sep 21, 2017 at 12:43
  • Check answer and it will sort out your issue.
    – Jarnail S
    Sep 22, 2017 at 12:00
  • I am also facing the same issue cant find the solution 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; this query not solve your issue if you save than agan checkbox uncheked Dec 6, 2018 at 7:00
  • Rather than copying the answer that didn't work and saying it doesn't get saved you'd be better to ask this as a new question. Just provide a link to this question in your new question and explain why the answer didn't work for you.
    – PeterJ
    Dec 6, 2018 at 7:31

9 Answers 9

26

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.

9
  • 3
    this may not be what I was looking for, but it will do the job. you answer did helped me. Sep 22, 2017 at 16:07
  • 1
    Thank you, your solution inspired me to write some queries to sync text info from store view categories to All store category. Mar 9, 2018 at 18:59
  • Good luck .. (y)
    – Jarnail S
    Mar 12, 2018 at 4:20
  • 1
    Thnk q.......+1 Nov 18, 2019 at 13:21
  • The issue is categories, not products. How does this solve the category issue. This answer did not work for us.
    – Scot
    Jan 17, 2020 at 17:11
3

I want to add something to the accepted solution. The solution will delete ALL product attributes linked to that store.

If u want to delete a specific product attribute you must check the eav_attribute table with the query:

select a.attribute_id, a.attribute_code, a.backend_type 
from eav_attribute as a
inner join eav_entity_type as e on (a.entity_type_id = e.entity_type_id)
where e.entity_type_code = 'catalog_product';

which will return a set of all attributes linked to a product in magento (default and custom attributes):

+--------------+--------------------------------+--------------+
| attribute_id | attribute_code                 | backend_type |
+--------------+--------------------------------+--------------+
|          429 | allow_message                  | int          |
|          399 | allow_open_amount              | int          |
|          578 | brand                          | int          |
|          590 | bundle_price                   | varchar      |
|          581 | bundle_qta                     | varchar      |
|          593 | categoria                      | int          |
                          ...

After you found the attribute_id you want to remove execute the delete query on the table relative to the backend_type field. For example, if we want to remove the brand attribute we will execute the following query:

delete from catalog_product_entity_int where attribute_id = 578 and store_id = 1;
2

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;
1
  • That does work to cause all "Use Default" boxes to be checked, but it still does not address the original request to cause all boxes in store view to automatically be checked to begin with. Why is M2 not automatically checking these boxes? This was not an issue in M1. We are running both, and I can verify this.
    – Scot
    Jan 17, 2020 at 18:07
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;
}
0

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.
0

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;

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

@Jarnail S

Thanks for solution

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;

I want to add this three more tables for product custom options

DELETE FROM `catalog_product_option_title` where `store_id` = 1;
DELETE FROM `catalog_product_option_type_price` where `store_id` = 1;
DELETE FROM `catalog_product_option_type_title` where `store_id` = 1;

Thanks.

0

First backup of your table:- catalog_product_entity_varchar then check how many items are there in the table with different store id.

Query

SELECT *
FROM `catalog_product_entity_varchar`
WHERE `store_id` != '0' AND `attribute_id` = '71'

Then download these records for your backup. after that you delete it.

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.