如何在 Magento 中允许重复的 SKU
我有一个零售第三方电池的客户,有些电池可以替代多种 OEM 型号。
例如,第 3 方 SKU 12345 可能会取代东芝 N23 和 HP 53214,因此我的客户希望创建两种前端具有相同 SKU 的产品(它们本质上是相同的产品)。 但是,Magento 默认情况下不允许重复的 SKU。
我目前的解决方案是从后端将SKU设置为不需要,并添加另一个名为Model的允许重复值的属性,并在前端显示Model。
有一个更好的方法吗? 或者是否可以允许重复的 SKU?
田波
贵族科技
I have a customer who retails third party batteries, and some batteries can replace several OEM models.
For instance, 3rd party SKU 12345 may replace Toshiba N23 and HP 53214, thus my customer would like to create two products with the same SKU in front end (they are essentially the same product). However, Magento by default does not allow duplicated SKU.
My current solution is to set SKU to not required from the backend, and add another attribute called Model that allows duplicated values, and display the Model in front end.
Is there a better way to do this? Or is it possible to allow duplicated SKU?
Tian Bo
Noble Technologies
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
在我看来,你已经找到了一个很好的解决方案。 我不太确定您应该尝试为 SKU 使用重复的值,原因有两个。
首先,SKU 的全部意义在于它是一个唯一标识符。 这是它存在的唯一理由。 如果您有重复的值,那么它就不是唯一标识符; 这只是另一个属性。 但当然,Magento 仍然需要一个唯一的标识符才能工作,这意味着这是一个额外的字段,它将我们准确地带到您现在所在的位置。
这就是说,我们来到了我的第二点,那就是……我不完全是 Magento 大师,但我已经建立了自己的电子商务网站,我学到的一件事是它们依赖于某些牢不可破的规则才能正常工作。 其中之一是唯一标识符在数据库和应用程序级别上都是唯一。 因此,网站的很大一部分依赖于此才能正常运行。 我很确定这也适用于 Magento。
因此,试图改变如此复杂的事情的基本前提只会导致恐怖并慢慢陷入疯狂。
It sounds to me like you've found a good solution. I'm not so sure you should try to have duplicate values for SKU for two reasons.
First the whole point of SKU is that it is a unique identifier. That's its only reason for existing. If you're going to have duplicate values, then it's not a unique identifier; it's just another attribute. But of course Magento still needs a unique identifier to work, which means that this is an extra field, which takes us exactly where you are now.
That said we come to my second point which is this... I'm not exactly a Magento guru, but I've built my share of e-commerce sites and one thing I've learned is that they depend on certain unbreakable rules to work properly. One of them is that unique identifiers are unique, both on the database and application level. As such, a large part of the website depends on this to function correctly. Which I'm pretty sure goes for Magento too.
So trying to change such a basic premise in something so complicated will only lead to horrors and a slow descent into madness.
这听起来像是一个很好的解决方案,我进一步扩展了一点,但是我对多个商店所做的是创建一个可见属性 ITEM_SKU(商品 SKU) - 使其可见且可搜索,然后将 store_id 连接到 Magneto SKU 以使其唯一。
这样SKU就变成了(Store_id“-”SKU)。
This sounds like a good solution that I extended a bit further, however what I did with multiple store was to create a visible attribute ITEM_SKU (Item SKU) - make it visible and searchable and then concatenate the store_id to Magneto SKU to make it unique.
So SKU becomes (Store_id "-" SKU).
让我惊讶的是,人们经常愿意破坏 Magento 的未知部分,只是为了让某个特定的部分按照他们的预期工作。
允许重复 sku 的正确方法是“不”(除非您想重写框架的大部分内容)。 但是,您可以向与“sku”共享所有相同设置的产品添加自定义属性,减去要求值唯一的设置。
更改产品页面、电子邮件等来显示此值将需要一些额外的工作,但会为您省去以后的麻烦。
It surprises me how often people are willing to break who-knows-what parts of Magento, just to get a specific piece working how they expect.
The proper way to allow for duplicate skus is NOT to (unless you'd like to re-write large parts of the framework). You CAN, however, add a custom attribute to products that shares all the same settings as "sku" minus the setting that requires values to be unique.
Changing product pages, emails, etc to show this value instead will require a little extra work but will save you headaches later.
您为什么不创建 1 个产品 (SKU 12345) 并在多个类别中列出该产品。 所以你的多个类别将是东芝和惠普。 相同的产品(SKU 12345)将在东芝和惠普上市。
Why don't you create 1 product (SKU 12345) and list this product in multiple categories. So your multiple categories will be Toshiba and HP. The same product (SKU 12345) will be listed in Toshiba and HP.