duanan5940 2010-06-28 06:39
浏览 48
已采纳

如何在Magento中以编程方式设置捆绑产品的Sku类型和价格类型?

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 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.

  • 写回答

1条回答 默认 最新

  • dsb238100 2010-06-28 15:37
    关注

    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!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿