Magento,catalog_product_flat 问题
我们的网站有 2 种商店视图:FR 和 EN。对于某些产品,导入 EN 商店视图的 catalog_product_flat
后不会刷新。在 EAV 表中一切都很好。数据重新索引应截断此平面表并用更新的数据填充它。不知怎的,它对某些项目不起作用。
你们中有人遇到过类似的问题吗?对于有关此主题的任何线索或建议,我将不胜感激。
编辑
我做了进一步的检查,我对 EAV 表的看法是错误的。事实证明,catalog_product_entity_varchar
与catalog_product_flat
一致。因此,平面表与 EAV 表具有相同的数据,但在管理面板中的值是错误的。对于 EN 商店视图,它们与默认值相同,仅适用于某些产品(神奇?;))。在我的本地电脑上我没有遇到这样的问题。这仅适用于我们的生产环境。据我所知,我们不使用任何数据库复制(这可能是这里的问题)。
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).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Magento 使用 EAV 数据库模型来轻松升级和开发,因为该模型提供了更大的灵活性来处理数据和属性。
当在 Magento 中启用平面目录时,上述所有产品属性(id、名称、价格)都将保存在一个名为catalog_product_flat 的表中。然后,Magento 从平面表中获取产品数据,而不是连接所有其他较小的表。
平面目录有两种类型:
1) 平面目录产品
2) 扁平目录类别
启用平面目录类别:
启用平面目录产品:
记住,最初的选择列表是
管理面板->系统->配置->目录->前端->使用平面目录产品
或者,
管理面板->系统->配置->目录->前端->使用平面目录 产品
不可编辑。您必须从缓存管理重建平面目录。只有这样,选择列表才可以编辑。
EAV database model is used by Magento for easy upgrade and development as this model gives more flexibility to play with data and attributes.
When flat catalog is enabled in Magento then all the above product attributes (id, name, price) are kept in one table named like catalog_product_flat. Then Magento fetches product data from the flat table rather than joining all the other smaller tables.
There are two types of Flat Catalog:
1) Flat Catalog Product
2) Flat Catalog Category
Enable Flat Catalog Category:
Enable Flat Catalog Product:
Remember that, initially the selection list of
Admin Panel->System->Configuration->Catalog->Frontend->Use Flat Catalog Product
OR,
Admin Panel->System->Configuration->Catalog->Frontend->Use Flat Catalog Product
is non-editable. You have to rebuild Flat Catalog from Cache Management. Only then the selection list becomes editable.
确保在导入目录产品时,在导入文件中为产品所需的属性提供了正确的值。如果未正确完成此操作,则数据重新索引可能无法正常运行。
此外,在重新索引之前,始终建议 &明智地从“
缓存管理
”中清除缓存从 Magento 安装目录的“cache
”文件夹中。希望有帮助。
Make sure that while importing of the Catalog Products, the required attributes of the products are provided with correct values in the import file. If this is not done properly, then Data re-index may not function correctly.
Also before re-indexing, it is always advisable & wise to clear the cache from the "
Cache Management
" & from the "cache
" folder of your Magento installation directory.Hope it helps.
我错了。数据库一切正常。问题是从数据库检索的属性的顺序。
在
Mage_Eav_Model_Entity_Abstract
中,我们可以发现:行
implode(' UNION ', $selects)
连接了所有 select 语句。但没有ORDER BY
,因此可以按随机顺序检索数据。事实上,对于某些产品来说是这样的。该选择采用商店视图 0(始终)和选定商店视图(当前视图)的属性值。数组
$values
包含具有 attribute 属性的数组。顺序在这里确实很重要,因为如果商店视图的属性(例如“名称”)(例如 1)将在商店视图 0 的属性之前进行,那么它将被覆盖。解决方案是将
ORDER BY
子句添加到$selects
或排序$values
数组。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_Abstract
we 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
$values
contains 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 BY
clause to the$selects
or sort$values
array.