Magento,catalog_product_flat 问题

发布于 2024-10-20 10:31:27 字数 473 浏览 2 评论 0原文

我们的网站有 2 种商店视图:FR 和 EN。对于某些产品,导入 EN 商店视图的 catalog_product_flat 后不会刷新。在 EAV 表中一切都很好。数据重新索引应截断此平面表并用更新的数据填充它。不知怎的,它对某些项目不起作用。

你们中有人遇到过类似的问题吗?对于有关此主题的任何线索或建议,我将不胜感激。

编辑

我做了进一步的检查,我对 EAV 表的看法是错误的。事实证明,catalog_product_entity_varcharcatalog_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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

谁的新欢旧爱 2024-10-27 10:31:27

Magento 使用 EAV 数据库模型来轻松升级和开发,因为该模型提供了更大的灵活性来处理数据和属性。

当在 Magento 中启用平面目录时,上述所有产品属性(id、名称、价格)都将保存在一个名为catalog_product_flat 的表中。然后,Magento 从平面表中获取产品数据,而不是连接所有其他较小的表。

平面目录有两种类型:
1) 平面目录产品
2) 扁平目录类别

  • 建议在任何 Magento 安装中使用扁平类别,以提高性能。
  • Flat Products 专为包含超过 1000 个 SKU 的目录而设计和推荐。

启用平面目录类别:

  • 转到管理面板->系统->缓存管理->重建平面目录类别
  • 转到管理面板->系统->配置->目录->前端->使用平面目录类别 = 是

启用平面目录产品:

  • 转到管理面板 -> 系统 -> 缓存管理 -> 重建平面目录产品
  • 转到管理面板 -> 系统 -> 配置 -> 目录 -> 前端 - >使用平面目录产品=是

记住,最初的选择列表是

管理面板->系统->配置->目录->前端->使用平面目录产品
或者,
管理面板->系统->配置->目录->前端->使用平面目录 产品

不可编辑。您必须从缓存管理重建平面目录。只有这样,选择列表才可以编辑。

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

  • Flat Categories are recommended for any Magento installation for improved performance.
  • Flat Products is designed and recommended for catalogs that have over 1000 SKU’s.

Enable Flat Catalog Category:

  • Go to Admin Panel->System->Cache Management->Rebuild Flat Catalog Category
  • Go to Admin Panel->System->Configuration->Catalog->Frontend->Use Flat Catalog Category = Yes

Enable Flat Catalog Product:

  • Go to Admin Panel->System->Cache Management->Rebuild Flat Catalog Product
  • Go to Admin Panel->System->Configuration->Catalog->Frontend->Use Flat Catalog Product = Yes

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.

满栀 2024-10-27 10:31:27

确保在导入目录产品时,在导入文件中为产品所需的属性提供了正确的值。如果未正确完成此操作,则数据重新索引可能无法正常运行。

此外,在重新索引之前,始终建议 &明智地从“缓存管理”中清除缓存从 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.

烟酒忠诚 2024-10-27 10:31:27

我错了。数据库一切正常。问题是从数据库检索的属性的顺序。

Mage_Eav_Model_Entity_Abstract 中,我们可以发现:


$selects = array();
foreach ($this->getAttributesByTable() as $table=>$attributes) {
   $selects[] = $this->_getLoadAttributesSelect($object, $table);
}
if (!empty($selects)) {
   $values = $this->_getReadAdapter()->fetchAll(implode(' UNION ', $selects));

   foreach ($values as $valueRow) {
      $this->_setAttribteValue($object, $valueRow);
   }
}

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:


$selects = array();
foreach ($this->getAttributesByTable() as $table=>$attributes) {
   $selects[] = $this->_getLoadAttributesSelect($object, $table);
}
if (!empty($selects)) {
   $values = $this->_getReadAdapter()->fetchAll(implode(' UNION ', $selects));

   foreach ($values as $valueRow) {
      $this->_setAttribteValue($object, $valueRow);
   }
}

Line implode(' UNION ', $selects) concatenates all select statements. But there is no ORDER 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文