We have a website with 2 store views: FR and EN. For some products after import catalog_product_flat for EN store view is not refreshed. In EAV tables everything is fine. Data re-index should truncate this flat table and fill it with updated data. Somehow it doesn’t work for some items.
Did anyone of you had a similar problem? I’d appreciate for any clues or advices on this topic.
EDIT
I have made further checks and I was wrong about EAV tables. It turns out that catalog_product_entity_varchar is consistent with catalog_product_flat. So flat table has the same data as EAV table but in the Admin Panel values are wrong. For EN store view they are the same as default values, only for some products (magic? ;)). On my local PC I didn’t encounter such issue. This is only on our production environment. As far as I know we do not use any DB replication (which could be the issue here).
I was wrong about what’s wrong. And everything is OK with database. The problem was an order of attributes that are retrieved from DB.
In
Mage_Eav_Model_Entity_Abstractwe can find:Line
implode(' UNION ', $selects)concatenates all select statements. But there is noORDER BY, so data can be retrieved in random order. As a matter of fact, for some of the products it is like this. That select takes values of attributes for store view 0 (always) and selected store view (current one).Array
$valuescontains of arrays with attributes properties. Order does matter here, because if attribute (for example ‘name’) for store view e.g. 1 will be proceed before one for store view 0, then it will be overwritten.Solution is to add
ORDER BYclause to the$selectsor sort$valuesarray.