可配置产品问题
我在使产品可配置时遇到问题,我使用了此链接 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以检查 2 件事:
2 things you can check:
可配置产品链接在 magento 中如何工作?
摆脱可配置产品与其简单对应产品链接的困扰?让我们解释一下 Magento 如何链接它们......以及为什么它有时不能按预期工作。
首先要了解的是应用程序如何管理数据持久性。正如预期的那样,链接存储在数据库中。以为它在 catalog_product_relation 中?你错了。尊重 Magento 的精神应该太简单了:)
catalog_product_relation 与catalog_product_super_* 表
我不会告诉catalog_product_relation 是无用的 - 事实上,它必然有某些用途。但从 1.5+ 版本开始,链接就不再存储了,我无法解释它的用途是什么。
第一步
链接过程的第一步是定义可配置产品的可配置属性。假设我们正在从具有一些全局选择属性的属性集创建一个新的可配置产品。
如果您尝试访问可配置产品,应用程序将询问您应将哪些属性用作可配置属性,并以使用与每个属性关联的复选框列表的形式。通过选择一些产品并保存产品,您可以按属性(产品 ID 与属性 ID 之间的关联)在 catalog_product_super_attribute 中插入一行。
第二步
第二步是将其自身与相关的简单产品链接起来。此步骤有点复杂,因为它意味着对数据库内容进行一些检查,我们将在下面进一步详细介绍。需要记住的一些规则:
,当我们进入可配置的关联产品选项卡时会发生什么?不要因为在显示的列表中看不到任何简单对应的产品而感到惊慌——它的过滤器默认配置为仅显示已链接的产品。以下是幕后发生的事情:
继续来说,只有具有有效值的产品才可显示并有效链接/可链接。请注意,所有组合都必须具有有效值 - 如果任何可配置属性为无,则游戏结束,您的简单产品与其可配置对应产品之间不会有任何链接。
我们应该认为没关系,现在一切都会顺利,因为我们知道数据库中的一切是如何工作的。如果您始终从应用程序的后台创建属性,则确实如此。但由于编写属性脚本是一种非常常见的处理方式,因此您很可能会遇到第二种情况,这意味着潜在的巨大问题。
以编程方式创建的属性和...到底是什么!?!该属性已更改后端类型!
这是我个人遇到的麻烦。如果您检查数据库中的属性后端模型(仅适用于选定的属性 - 我们不关心哪些属性不可用作可配置的属性),您会看到一些 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 个步骤:
这里有一些 MySQL 脚本,对应于这些步骤,假设您有首先列出相关属性代码的列表:
检查实体 int 中的现有条目以获取给定的属性代码列表
将实体_varchar 表(例如)中的条目复制到实体_int 以获取给定的属性代码列表
更新属性以不再出现问题!
从数据库中删除不再使用的条目
希望它能帮助所有无法让其关联产品出现的人获得窍门!
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 :
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 :
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 !
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 :
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
Duplicate entries from entity_varchar table (for example) to entity_int for a given list of attribute codes
Update attributes to never have the problem again!
Remove the no more used entries from your database
Hope it will help all of the ones who can't make their associated products show up to get the trick!