可配置产品问题

发布于 2024-09-25 08:31:40 字数 276 浏览 2 评论 0原文

我在使产品可配置时遇到问题,我使用了此链接 http://www.magentocommerce.com/knowledge-base/entry/tutorial-creating-a-configurable-product/,但在关联的选项卡中,产品没有显示

谢谢和问候

I am facing a problem while making product configurable i used this link http://www.magentocommerce.com/knowledge-base/entry/tutorial-creating-a-configurable-product/ but In associated tab the products doesnt show up

Thankds and regards

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

凉墨 2024-10-02 08:31:40

您可以检查 2 件事:

  • 您确定要关联到可配置产品的简单产品实际上具有用于配置可配置产品的属性值吗?因此,如果您制作了基于“颜色”的可配置产品,那么简单产品是否为“颜色”选择了值?
  • 当您查看关联的产品选项卡并看到那里的空白网格时,您是否尝试过重置过滤器,或在第一列中选​​择“否”或“任何”?如果设置为“是”,则仅查找已关联的产品。

2 things you can check:

  • Are you sure that the simple products you want to associate to the configurable product actually have values for the attribute you made the configurable product configurable by? So if you made a configurable product based on 'color', do the simple products have values selected for 'color'?
  • When you are looking at the associated products tab, and seeing the blank grid there, have you tried resetting the filter, or selecting 'No' or 'Any' in the first column? If it is set to 'Yes', it is only looking for products that have already been associated.
街道布景 2024-10-02 08:31:40

可配置产品链接在 magento 中如何工作?

摆脱可配置产品与其简单对应产品链接的困扰?让我们解释一下 Magento 如何链接它们......以及为什么它有时不能按预期工作。

首先要了解的是应用程序如何管理数据持久性。正如预期的那样,链接存储在数据库中。以为它在 catalog_product_relation 中?你错了。尊重 Magento 的精神应该太简单了:)

catalog_product_relation 与catalog_product_super_* 表

我不会告诉catalog_product_relation 是无用的 - 事实上,它必然有某些用途。但从 1.5+ 版本开始,链接就不再存储了,我无法解释它的用途是什么。

第一步

链接过程的第一步是定义可配置产品的可配置属性。假设我们正在从具有一些全局选择属性的属性集创建一个新的可配置产品。

如果您尝试访问可配置产品,应用程序将询问您应将哪些属性用作可配置属性,并以使用与每个属性关联的复选框列表的形式。通过选择一些产品并保存产品,您可以按属性(产品 ID 与属性 ID 之间的关联)在 catalog_product_super_attribute 中插入一行。

第二步

第二步是将其自身与相关的简单产品链接起来。此步骤有点复杂,因为它意味着对数据库内容进行一些检查,我们将在下面进一步详细介绍。需要记住的一些规则:

  • 只有与当前可配置产品选项具有相同属性集的产品才
  • 必须为可配置属性定义,对于
  • 给定的可配置属性组合,只能链接一个简单的简单
  • 可以链接到尽可能多的可配置然后

,当我们进入可配置的关联产品选项卡时会发生什么?不要因为在显示的列表中看不到任何简单对应的产品而感到惊慌——它的过滤器默认配置为仅显示已链接的产品。以下是幕后发生的事情:

  1. 应用程序检查 catalog_product_super_attribute 表,并从中返回为当前产品定义的每个相应属性 ID(我们的可配置属性)
  2. ,它将检查 < strong>eav_attribute 来获取有关它们的一些详细信息 - 其中 backend_type(这是此解释中更重要的部分
  3. )同时检查 catalog_product_super_link 表也。链接到 current_product 的任何产品都是每个属性的潜在链接产品
  4. ,应用程序会检查每个潜在链接产品的 catalog_product_entity_{backend_type} 中是否存在值。请注意,如果给定产品不存在任何值,则它不会被验证,也不会作为潜在链接或有效链接,即使它已经被链接(我们将在下面看到它对属性创建意味着什么)。

继续来说,只有具有有效值的产品才可显示并有效链接/可链接。请注意,所有组合都必须具有有效值 - 如果任何可配置属性为无,则游戏结束,您的简单产品与其可配置对应产品之间不会有任何链接。

我们应该认为没关系,现在一切都会顺利,因为我们知道数据库中的一切是如何工作的。如果您始终从应用程序的后台创建属性,则确实如此。但由于编写属性脚本是一种非常常见的处理方式,因此您很可能会遇到第二种情况,这意味着潜在的巨大问题。

以编程方式创建的属性和...到底是什么!?!该属性已更改后端类型!

  • 编辑注意:当使用 eav/entity_attribute_source_table 源模型时,这种情况会有效地发生,

这是我个人遇到的麻烦。如果您检查数据库中的属性后端模型(仅适用于选定的属性 - 我们不关心哪些属性不可用作可配置的属性),您会看到一些 varchar,一些 int...简而言之,多个属性,我们可以正确地期望它们中的任何一个都能起作用。

他们也这样做了。由于您不决定从后台向您的属性添加选项,或者任何其他需要单击“保存”的选项属性页上的按钮。

关键是,当你保存你的属性时,Magento,在它伟大的善良中,问问自己你要求他保存的属性的类型是什么。重点是,首先是选择。选择有选项。并且选项有 id。在任何情况下,哪些值将被放入 catalog_product_entity_{backend_type} 中。标签只是被正确地忽略(它存储在正确的表中并且不会影响那里的任何内容)。仅使用 id。

我们对 Magento 有何期望:) ?

它只是系统地将属性后端类型更改为int。

因此,如果您有曾经链接过的产品,但现在不再存在,请检查 catalog_product_entity_{backend_type} 表和 eav_attribute 表 - 比较后端类型,在每个值表中查找值。如果您在不对应的表中发现它们,您就会遇到问题。你有几种方法可以纠正这个问题,这是我自己发现的两种方法(我真的不提倡第一种,我只是为了解释目的而提出的)。

第一种方法:获取后端类型(The Dirty Trick)

它已更改为 int ?别在意。将其恢复到您想要的样子。

为什么它很脏 :因为您希望用户能够在需要时更新其属性。例如,如果将后端类型更新为 varchar,则后台中选项的任何标签更改都将回滚为 int,因为它将被保存。

第二种方法:让我们纠正一切! (正确的事情)

您可以通过一些 MySQL 来度过这个...糟糕的情况,而不会损害您的数据库。但请先把它扔掉。那么您需要执行 4 个步骤:

  1. 检查 catalog_product_entity_int 表中是否还没有数据,
  2. 复制当前...实体的行{ attribute} 表到 ..._entity_int 通过使用 INSERT / SELECT 语句(此查询可能有点长)
  3. 更新您的可配置属性(不是所有属性,仅是那些您知道您已经创建并用于设置可配置产品)将其后端类型设置为 int (并且不再为可配置选择执行其他操作:))
  4. 删除与 ..._entity{attribute 中的属性相对应的所有条目您将不再使用的表(它可以做很多条目,因为如果您有很多选项,您可以拥有很多产品)

这里有一些 MySQL 脚本,对应于这些步骤,假设您有首先列出相关属性代码的列表:

检查实体 int 中的现有条目以获取给定的属性代码列表

-- Check existing entries to not duplicate
    SELECT  ea.attribute_code,
        count(*)
    FROM eav_attribute as ea
    INNER JOIN catalog_product_entity_int as cpei
    ON ea.attribute_id = cpei.attribute_id
    WHERE ea.attribute_code IN(
        {attributeCodesList}
    )
    GROUP BY ea.attribute_code

将实体_varchar 表(例如)中的条目复制到实体_int 以获取给定的属性代码列表

-- Duplicating missed selects from varchat entity table to int
INSERT INTO catalog_product_entity_int (entity_type_id, attribute_id, store_id, entity_id, value)
SELECT  cpev.entity_type_id,
    cpev.attribute_id,
    cpev.store_id,
    cpev.entity_id,
    cpev.value
FROM eav_attribute as ea
INNER JOIN catalog_product_entity_varchar as cpev
ON ea.attribute_id = cpev.attribute_id
WHERE ea.attribute_code IN(
    {attributeCodesList}
)

更新属性以不再出现问题!

-- Update missed select attributes from varchar backend type to int one
UPDATE  eav_attribute as ea 
SET     ea.backend_type = 'int'
WHERE   ea.attribute_code IN (
    {attributeCodesList}
)

从数据库中删除不再使用的条目

-- Kill old varchar in varchar entity table
DELETE FROM catalog_product_entity_varchar
WHERE attribute_id IN (
    SELECT ea.attribute_id
    FROM eav_attribute as ea
    WHERE ea.attribute_code IN (
        {attributeCodesList}
    )
)

希望它能帮助所有无法让其关联产品出现的人获得窍门!

How does configurables products linking works in magento ?

Getting rid of being trolled by the linking of configurables products with their simple counterparts ? Let's explain how does Magento link'em... and why it sometimes doesn't work as expected.

The first point to understand is how the data persistence is managed by the application. As expected, links are stored in database. Thought it was in catalog_product_relation ? You were wrong. It should be too simple to respect the Magento's spirit :)

catalog_product_relation vs catalog_product_super_* tables

I won't tell catalog_product_relation is useless – in fact, it's necessarily there for something. But from version 1.5+, this is not there that links are stored, and I can't explain what does its purpose is.

First step

The first step of the linking process is the definition of the configurable product's configurable attributes. Supposing we're creating a new configurable product from an attribute set having a few global-select attributes.

If you try to access to your configurable product, the application will ask you which of 'em should be used as configurable attributes, in a form using a list of checkboxes associated to each attribute. By selecting some and saving your product, you insert in catalog_product_super_attribute a row by attribute (an association between product's id and attribute's one).

Second step

The second step is the linking itself with the associated simple products. This step is a bit more complex, because it implies some checks of the database's content, which we'll detail further below. Some rules to keep in mind about that :

  • only products having the same attribute set as the current configurable product
  • options must be defined for the configurable attribute
  • only one simple can be linked for a given configurable attribute combination
  • simple can be linked to as many configurables as desired

Then, what happens when we go to our configurable's associated products tab ? Don't be scray to not see any of your simple-corresponding-product in the list that display – it's filter is configured by default to display only already linked products. Here is what happens behind the scene :

  1. the application go check the catalog_product_super_attribute table, and bring back each corresponding attribute id defined there for the current product (our configurables attributes)
  2. from them, it will go check eav_attribute to get some details about them – in which ones the backend_type, which is the more important part of this explanation
  3. parallely, the catalog_product_super_link table is checked too. Any product linked to current_product is a potential linked product
  4. for each attribute, the application check if a value exists in catalog_product_entity_{backend_type} for each potentially linked product. Note that if no value exists for a given product, it won't be validated nor as a potential link nor than an effective one, even if it has already been linked (we'll see below what it implies for attribute creation).

To resume, only products with a valid value are diplayable and effectively linked / linkable. Note that all of the combination must have valid values – if any of the configurable's attribute as none, game over, you'll not have any link between your simple product and its configurable counterpart.

We should think it's ok, and everything will go right now, since we know how everything works in database. That's true if you always create your attributes from the application's back-office. But since scripting attributes is a very common way to proceed, you're much like to be in this second case, which implies a potential HUGE problem.

Programatically created attributes and... What the hell !?! This attribute has change of backend type !

  • Edit note: this case happens effectively when using a eav/entity_attribute_source_table source model

This a trouble I personnally runned through. If you check attributes backend models in database (only for select attributes – we do not care about which ones are not usable as configurable's ones), you'll see some varchar, some int... In short, multiple ones, and we could rightfully expect any of them works.

And they do so. Since you do not decide to add an option to your attribute from the back-office, or anything else that require to click on the « save » button on the attribute page.

The point is that when you save your attribute, Magento, in it's great goodness, ask itself what is the type of the attribute you ask him to save. The point is that before anything else, it's a select. And a select has options. And options has id. Which are the values that will be put in catalog_product_entity_{backend_type}, in any case. The label is just properly ignored in that (it's stored in it's proper table and doesn't affect anything there). Only the id is used.

And what shall we expect from Magento :) ?

It just change the attribute backend type to int systematically.

So, if you have products that used to be linked and are no more, go check the catalog_product_entity_{backend_type} tables and the eav_attribute one – compare the backend type, look for values in each values table... If you find 'em in a table that does not correspond, you get your problem. You have a few ways to correct the problem, here are the both I find myself (and I really do not promote the first, which I put only for explanation purpose).

First way: get the backend type back (The Dirty Trick)

It has changed to int ? Don't care. Bring it back to what you want it to be.

Why it's dirty : because you want you user to be able to update it's attributes when he wants. If you update the backend type to varchar, for example, any label change in the back-office for an option will rollback to int as it will be saved.

Second way: let's correct everything ! (The Right Thing)

You can pass throught this... bad situation, with a bit of MySQL without harming your database. But please, first, dump it. Then you'll require 4 steps :

  1. check that you don't already have the data in catalog_product_entity_int table
  2. duplicate the rows of the current ...entity{attribute} table to the ..._entity_int one by using an INSERT / SELECT statement (this query can be a bit long)
  3. update your configurable attributes (not all your attributes, ONLY the ones you know you have created and are use to set configurable products) to set their backend type to int (and never do something else again for configurable selects :) )
  4. delete all entries corresponding to attribute in the ..._entity{attribute} table that you'll no more use (it can do pretty much entries since you can have a lot of products if you get a lot of options)

Here are some MySQL scripts, corresponding to these steps, supposing you have at start a list of the attributes codes concerned :

Check existing entries in entity int for a given list of attribute codes

-- Check existing entries to not duplicate
    SELECT  ea.attribute_code,
        count(*)
    FROM eav_attribute as ea
    INNER JOIN catalog_product_entity_int as cpei
    ON ea.attribute_id = cpei.attribute_id
    WHERE ea.attribute_code IN(
        {attributeCodesList}
    )
    GROUP BY ea.attribute_code

Duplicate entries from entity_varchar table (for example) to entity_int for a given list of attribute codes

-- Duplicating missed selects from varchat entity table to int
INSERT INTO catalog_product_entity_int (entity_type_id, attribute_id, store_id, entity_id, value)
SELECT  cpev.entity_type_id,
    cpev.attribute_id,
    cpev.store_id,
    cpev.entity_id,
    cpev.value
FROM eav_attribute as ea
INNER JOIN catalog_product_entity_varchar as cpev
ON ea.attribute_id = cpev.attribute_id
WHERE ea.attribute_code IN(
    {attributeCodesList}
)

Update attributes to never have the problem again!

-- Update missed select attributes from varchar backend type to int one
UPDATE  eav_attribute as ea 
SET     ea.backend_type = 'int'
WHERE   ea.attribute_code IN (
    {attributeCodesList}
)

Remove the no more used entries from your database

-- Kill old varchar in varchar entity table
DELETE FROM catalog_product_entity_varchar
WHERE attribute_id IN (
    SELECT ea.attribute_id
    FROM eav_attribute as ea
    WHERE ea.attribute_code IN (
        {attributeCodesList}
    )
)

Hope it will help all of the ones who can't make their associated products show up to get the trick!

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