【问题标题】:Magento Bundle Product - Multiple Options with Same products. How to stop Magento from hiding the repetitive products?Magento 捆绑产品 - 具有相同产品的多个选项。如何阻止 Magento 隐藏重复产品?
【发布时间】:2013-03-08 22:51:51
【问题描述】:

我正在尝试在 Magento 中设置捆绑产品。此产品应允许客户选择 4 个免费产品以包含在捆绑包中。这些产品可以是完全不同的,也可以是同一产品的 4 个。

例如

免费产品 1 免费产品 2 免费产品 3

客户可以选择免费产品 1 中的四个,或免费产品 1 和 2 中的一个,以及免费产品 3 中的两个。

我正在使用 4 种下拉输入类型,每种都有所有三种免费产品作为选项。因此,客户可以为每个免费礼品订单项选择三种产品中的任何一种。

Magento 只显示一个下拉选择列表,我相信是因为每个下拉列表都包含相同的产品列表。

我需要在哪里查看以阻止 Magento 检查产品选项是否已在先前的选择中列出?

【问题讨论】:

    标签: magento product


    【解决方案1】:

    除非您以编程方式执行此操作(即编写代码),否则无法执行此操作。

    当 Magento 添加产品时,它首先查看报价/购物车以查看是否已经存在。如果有,它会拉出那个并增加数量。无法关闭此功能。

    以编程方式,您非常手动地将商品添加到购物车。就是这样……

    $cart = Mage::getSingleton("checkout/cart");
    
    foreach ($products_to_add as $product_id => $custom_options) {
      $product = Mage::getModel("catalog/product")->load($product_id);
      $options = new Varien_Object(array("options" => $custom_options,
                                         "qty" => 1));
    
      // some products may result in multiple products getting added to cart
      // I beleive this pulls them all and sets the custom options accordingly
      $add_all = $product->getTypeInstance(true)
          ->prepareForCartAdvanced($options, $product, Mage_Catalog_Model_Product_Type_Abstract::PROCESS_MODE_FULL);
    
      foreach ($add_all as $add_me) {
        $item = Mage::getModel('sales/quote_item');
        $item->setStoreId(Mage::app()->getStore()->getId());
        $item->setOptions($add_me->getCustomOptions())
          ->setProduct($add_me);
    
        $item->setQty(1);
        $cart->getQuote()->addItem($item);
      }
    }
    
    // when done adding all the items, finally call save on the cart
    $cart->save();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-06-16
      • 2014-12-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-30
      • 1970-01-01
      相关资源
      最近更新 更多