TransWikia.com

Magento 2 Price not updating in all store views when scope set to global

Magento Asked on December 19, 2021

In my magento 2.3.5 instance I am trying to switch price to global scope. I don’t need the function to have different price for a product in each store view.

Unfortunately this store is migrated from magento 1 and there I wasn’t use Global scope for price.

So now in Magento 2 when I switch price to global magento isn’t taking the default store view price to all store views. Because of my large catalog some products had in some store views different price than default store view.

I can identify the products and when I edit them I see the right price in default store view and the wrong price in another store view.

But when I try to change the wrong price, when I press save magento is changing the price in default store only and in the other store view I have the old wrong price.

Has anyone this issue? Is there a way to solve this without changing all my catalog prices?

I only need to change scope to global and keep default store view price to all my store views

One Answer

There is a problem in Magento that it doesn't take price scope into account while loading product EAV attributes. As a solution, you can tweak core code

MagentoEavModelResourceModelReadHandler::execute

Or remove obsolete data manually how is described below. Product price data is stored in catalog_product_entity_decimal MySQL table. You should delete all records for price attribute where store_id is not 0. Lookup price attribute ID by query:

SELECT `attribute`.`attribute_id` 
FROM `eav_attribute` AS `attribute` 
WHERE `attribute`.`attribute_code` = 'price' AND `attribute`.`entity_type_id` = (
    SELECT `entity_type`.`entity_type_id` FROM `eav_entity_type` AS `entity_type` WHERE `entity_type`.`entity_type_code` = 'catalog_product'
);

Price attribute ID equals to 77 in our case. Query to select obsolete price records

SELECT * FROM `catalog_product_entity_decimal` WHERE `store_id` <> 0 AND `attribute_id` = 77;

The result should be not empty in your case. To remove records run the query

DELETE FROM `catalog_product_entity_decimal` WHERE `store_id` <> 0 AND `attribute_id` = (SELECT `attribute`.`attribute_id` 
FROM `eav_attribute` AS `attribute` WHERE `attribute`.`attribute_code` = 'price' AND `attribute`.`entity_type_id` = (
    SELECT `entity_type`.`entity_type_id` FROM `eav_entity_type` AS `entity_type` WHERE `entity_type`.`entity_type_code` = 'catalog_product'
));

Finally, reindex data

php bin/magento indexer:reindex

Important Note! Backup your database before manipulations to be able to restore it if needed.

Answered by eComBricks on December 19, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP