Magento: программно создавать продукты в комплекте и настраиваемые продукты

Я попытался использовать следующий код изVinai в создании заказа, но это работает только в простых продуктах. Я уже пытался поиграть с ключами и значениями в $ buyInfo, но, похоже, заказ не будет выполнен. Я могу что-то упустить?

<code>$quote = Mage::getModel('sales/quote')
        ->setStoreId(Mage::app()->getStore('default')->getId());

if ('do customer orders') {
        // for customer orders:
        $customer = Mage::getModel('customer/customer')
                ->setWebsiteId(1)
                ->loadByEmail('[email protected]');
        $quote->assignCustomer($customer);
} else {
        // for guesr orders only:
        $quote->setCustomerEmail('[email protected]');
}

// add product(s)
$product = Mage::getModel('catalog/product')->load(8);
$buyInfo = array(
        'qty' => 1,
        // custom option id => value id
        // or
        // configurable attribute id => value id
);
$quote->addProduct($product, new Varien_Object($buyInfo));

$addressData = array(
        'firstname' => 'Test',
        'lastname' => 'Test',
        'street' => 'Sample Street 10',
        'city' => 'Somewhere',
        'postcode' => '123456',
        'telephone' => '123456',
        'country_id' => 'US',
        'region_id' => 12, // id from directory_country_region table
);

$billingAddress = $quote->getBillingAddress()->addData($addressData);
$shippingAddress = $quote->getShippingAddress()->addData($addressData);

$shippingAddress->setCollectShippingRates(true)->collectShippingRates()
                ->setShippingMethod('flatrate_flatrate')
                ->setPaymentMethod('checkmo');

$quote->getPayment()->importData(array('method' => 'checkmo'));

$quote->collectTotals()->save();

$service = Mage::getModel('sales/service_quote', $quote);
$service->submitAll();
$order = $service->getOrder();
</code>

Любая идея о том, как заставить это работать также в связанных и настраиваемых продуктах? Спасибо!

Ответы на вопрос(1)

Ваш ответ на вопрос