2013-06-19 158 views
3

我想在另一个捆绑产品中添加捆绑产品。 达到我的地位很简单。编辑文件/app/code/Mage/Bundle/etc/config.xml这样的:Magento - 捆绑产品捆绑产品(几乎工作)

   ... 
       <allowed_selection_types> 
        <simple/> 
        <bundle/> <!-- Add this at line 104--> 
        <virtual/> 
       </allowed_selection_types> 
       ... 

通过这样做,你就可以成功创建捆绑产品,它内部的另一种捆绑产品!

我的问题是,我不能通过AdminPanel或SOAP将该产品添加到订单中(没有尝试过槽前端,但可能不起作用)。

当我点击“添加所选产品(第)订购”管理小组,我得到以下错误:发生

[19-Jun-2013 15:52:48 UTC] PHP Fatal error: Call to a member function getPosition() on a non-object in app\code\core\Mage\Bundle\Model\Product\Type.php on line 865 

坠毁在shakeSelections($a, $b):代码$a->getOption()不会返回一个对象。它不是null,它也不是一个对象(我是一个PHP noobie,所以对我来说没有意义)。

== ==更新

现在我能够将这种新的产品加入到购物车!我编辑的文件的应用程序\代码\核心\法师\包\型号\产品\ Type.php,所以现在我有以下代码:

... 
/* 
* Create extra attributes that will be converted to product options in order item 
* for selection (not for all bundle) 
*/ 
$price = $product->getPriceModel()->getSelectionFinalTotalPrice($product, $selection, 0, $qty); 
$attributes = array(
     'price'   => Mage::app()->getStore()->convertPrice($price), 
     'qty'   => $qty, 
     'option_label' => is_null($selection->getOption()) ? '' : $selection->getOption()->getTitle(), 
     'option_id'  => is_null($selection->getOption()) ? 0 : $selection->getOption()->getId() 
); 

$type = $selection->getTypeInstance(true); 
if (get_class($type) != 'Mage_Bundle_Model_Product_Type'){ 
    $_result = $selection->getTypeInstance(true)->prepareForCart($buyRequest, $selection); 
} 
... 

和也低于功能:

public function shakeSelections($a, $b) 
{ 
    $ta = $a->getOption(); 
    $tb = $b->getOption(); 

    $aPosition = array(
      is_null($ta) ? 0 : $ta->getPosition(), 
      $a->getOptionId(), 
      $a->getPosition(), 
      $a->getSelectionId() 
    ); 
    $bPosition = array(
      is_null($tb) ? 0 : $tb->getPosition(), 
      $b->getOptionId(), 
      $b->getPosition(), 
      $b->getSelectionId() 
    ); 
    if ($aPosition == $bPosition) { 
     return 0; 
    } else { 
     return $aPosition < $bPosition ? -1 : 1; 
    } 
} 

我正在调查以发现我已经介绍的可能的副作用。在这一刻,我发现捆绑产品的库存管理存在问题。

如果你走得更远,请发布你的更新。非常感谢!

==第二个编辑==

我已经开始这个回购在github上,这样就可以按照我的进步,也许帮我弄好了。

https://github.com/matheusjadimb/MagentoBundleOfBundled

+0

当你得到一个任务将你的1.7升级到1.9时,你的核心文件将被覆盖,你将会很难过。 – bogatyrjov

回答

2

只是不这样做!

我有很多困难时期试图让这个工作正常。我了解到,您应该创建自己的产品类型,而不是编辑现有的产品类型。