2013-06-19 254 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

只是不這樣做!

我有很多困難時期試圖讓這個工作正常。我瞭解到,您應該創建自己的產品類型,而不是編輯現有的產品類型。