使用简单商品的 SKU/ID 以编程方式在 Magento 中添加捆绑产品
我在 Magento 中有一些简单的目录产品,所以我有他们的 SKU 和身份证。现在我想使用数组元素“bundle_options”和“bundle_options”创建一个捆绑产品。捆绑项目的“bundle_selections”,由 Magento 管理编码在其观察者类中使用。
同样在Observer类中,还有两个函数“setBundleOptionsData()
”和“setBundleOptionsData()”的方法调用。 “setBundleSelectionsData()
”,我无法找到其任何函数定义。
请这里有任何专业的帖子,因为我需要一些正确的方法来做这件事。如果需要,覆盖模块或使用事件,我会做,但我需要真正专业的帮助。 提前致谢。
编辑:-
关于上面提到的两个方法“setBundleOptionsData()
”& “setBundleSelectionsData()
”,我几乎可以肯定他们正在使用某种PHP魔法方法,但我不知道这些魔法方法的主要逻辑写在哪里?
请任何人提供一些正确的答案。非常感谢任何帮助。
I have some simple catalog products in Magento, so I have their SKUs & IDs. Now I want to create a Bundled product using the array elements "bundle_options" & "bundle_selections" of the Bundle Items, which are used by the Magento Admin coding in its Observer Class.
Also in the Observer class, there are method calls of two functions "setBundleOptionsData()
" & "setBundleSelectionsData()
", for whose I am not able to find any function definition.
Please any professional post here, because I need some proper way of doing this thing. If it needs, overriding modules or using events, I will do, but I need really professional help.
Thanks in advance.
Edit:-
Regarding the two methods mentioned above "setBundleOptionsData()
" & "setBundleSelectionsData()
", what I'm almost certain is that they are using some sort of PHP magic methods, but I don't know where the main logic of these magic methods are written?
Please anybody provide some correct answer. Any help is greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
对此感到很困难,但发现这让我克服了困难:
具体来说,这
是关键
编辑::
尝试添加多个选项/选择时,看起来也有一些特殊之处。 setBundleOptionsData 接受一个选项数组,
即然后选择将是一个选择数组的数组,其索引对应于选项数组:
Was having a hard time with this, but found that this got me over the hump:
Specifically, the
was the key
EDIT::
Also looks like there's a bit of a peculiarity when trying to add multiple options / selections. The setBundleOptionsData takes an array of options i.e.
And then the selections will be an array of selections arrays with their indexes corresponding to the options array:
或
$optionModel = Mage::getModel('bundle/option')
->addSelection('op111')
->setTitle('op111')
->setDefaultTitle('op111')
->setParentId($product_id)
->setStoreId($product->getStoreId());
$optionModel->save();
or
$optionModel = Mage::getModel('bundle/option')
->addSelection('op111')
->setTitle('op111')
->setDefaultTitle('op111')
->setParentId($product_id)
->setStoreId($product->getStoreId());
$optionModel->save();
为此,我没有使用任何网络服务。我只是使用了以下专门针对捆绑产品的方法,它们是: -
对于第一种方法,捆绑选项的详细信息作为表单中的参数提供给该方法一个数组的。类似地,对于第二个方法“setBundleSelectionsData()”,我们以数组的形式将 Bundle Selections 的详细信息作为参数提供给该方法。
这是在 Magento 中添加任何捆绑产品的主要逻辑。
希望这对任何新手都有帮助!
请检查此链接有关以正确方式创建捆绑产品的更多详细信息。
I am not using any Web Services, for this. I have simply used the following methods meant specifically for the Bundled Products, which are:-
For the first method, the details of the Bundle Options are provided to the method as the parameter in the form of an array. Similarly, for the second method "setBundleSelectionsData()", we are providing the details of the Bundle Selections to this method as the parameter in the form of an array.
This is the main logic in what goes through for adding any Bundled Product in Magento.
Hope this helps to any newbies!!!
Please check this link for more details on Bundle Product creation in a proper way.