3

別のバンドル製品内にバンドル製品を追加しようとしています。私のステータスを達成するのはとても簡単です。/app/code/Mage/Bundle/etc/config.xml次のようにファイルを編集します。

                ...
                <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 初心者なので、意味がわかりません)。

==アップデート==

これで、この新しい種類の製品をカートに追加できるようになりました! ファイル app\code\core\Mage\Bundle\Model\Product\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;
    }
}

私が導入した可能性のある副作用を発見するために調査しています。現時点では、このバンドル製品のバンドルの在庫管理に問題があることがわかります。

さらに進んだら、最新情報を投稿してください。どうもありがとう!

== 2 番目の編集 ==

私は github でこのレポを開始したので、私の進捗状況をフォローして、何らかの形で私を助けることができます。

https://github.com/matheusjadimb/MagentoBundleOfBundled

4

1 に答える 1

2

ただそれをしないでください!

これを適切に機能させるのに苦労しました。既存の商品タイプを編集するのではなく、独自の商品タイプを作成する必要があることを学びました。

于 2015-05-21T12:11:50.127 に答える