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 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀