3
我在创建销售/ quote_address对象并将其添加到多向结算结帐流程时遇到问题。目前,无论何时我创建一个新的地址对象,它只是重复使用完全相同的对象;因此,当我将项目添加到一个地址时,它会将它们添加到所有地址。作为一个检查,我在我的主循环之后放了一个for循环来回显所有创建地址的ID - 它总是回显数字3.当我尝试动态更改新创建的地址的ID时(注释掉部分)他们甚至不会在最后的循环中出现。我的代码如下:以编程方式创建销售/ quote_address对象的Magento
//dynamically create the addresses and add them to the shipping information screen
$idCounter = 1;
foreach($dropshippersCombineWProducts as $dropshippersWCProducts) {
$newAddress = null;
$newAddress = Mage::getSingleton('sales/quote_address')->importCustomerAddress($customAddress);
//$idCounter++;
//$newAddress->setId($idCounter);
foreach ($newAddress->getItemsCollection() as $item) {
$item->isDeleted(true);
}
foreach ($dropshippersWCProducts[1] as $_item) {
$newAddress->addItem($_item);
}
$quote->setShippingAddress($newAddress);
$newAddress->collectShippingRates();
}
$addresses = $quote->getAllShippingAddresses();
foreach ($addresses as $address) {
echo $address->getId();
}
任何帮助将不胜感激。