开发者

How to set Sku Type & Price Type of Bundle Product programmatically in Magento?

I have added a Bundled Product in Magento programmatically, using all the options / properties of the Simple Product & the use of the 3 methods specifically for Bundle Options:-

  1. setBundleOptionsData()
  2. setBundleSelectionsData()
  3. setCanSaveBundleSelections()

The result is that the newly added Bundle Product shows just fine in the Admin section, with some default values taken of the following properties:-

  1. sku_type
  2. weight_type
  3. shipment_type
  4. price_view
  5. price_type

However, this Bundle Product is not showing in the front-end at all, I don't know why. Can please somebody help me out? I have tried searching but to no avail. Please anybody please suggest as to what I'm doing wrong?

Also I need to开发者_Go百科 control the above-mentioned special properties of Bundle Product, so that they can be modified also during programmatically insertion. Can anybody please help me in this point also?

Any help is greatly appreciated.


After quite a lot of testings, I have found some way inside it.
If you look very clearly the "saveAction()" method, in the "ProductController.php" page of the "Adminhtml" module, you will find there is a line like "$product->save();".

If you make some inroads into this "save()" method, you will see that Magento is using some "setData()" method, for the simple product's properties.

So if you are using the "price", "weight", "sku", "name", "description", "short_description", ... fields as an 1D array, you just need to add the required properties of the Bundle Product to this array list, and Magento will do the rest.

So what I mean is that the array will contain the following elements as simple as that:-

Array
(
  ['name'] => 'simple',
  ['description'] => 'test',
  ['short_description'] => 'simple test',
  ['sku_type'] => 0,
  ['sku'] => 'simple01',
  ['weight_type'] => 1,
  ['weight'] => 12,
  ['price_type'] => 1,
  ['price'] => 250,
  ['shipment_type'] => 0
)

Now you need to pass this array through the "setData()" method, and bingo you go.

Just remember that Magento is really beautiful if you believe, otherwise it is as harsh & rude.
Hope it helps!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜