Php Magebto 1.9:以编程方式添加、更新和删除产品会返回错误的结果

Php Magebto 1.9:以编程方式添加、更新和删除产品会返回错误的结果,php,api,magento,Php,Api,Magento,在我的应用程序中,我以编程方式执行不同的操作,如添加、更新和删除购物车项目,因此我面临的问题是,当我将产品添加到购物车中时,更新或删除产品,然后运行代码获取最新的购物车项目,我得到的结果错误,这意味着获取上一步的结果。e、 g 将产品添加到购物车中,在获取购物车项目后,我将以空数组获取项目,在下一次调用获取购物车时,我将获取正确的记录 更新产品数量,然后get cart返回以前的商品数量,因此,如果我有一个产品,并且它在cart中的数量为1,并且我更新了数量,我在cart中仍然得到1,在第二次调

在我的应用程序中,我以编程方式执行不同的操作,如添加、更新和删除购物车项目,因此我面临的问题是,当我将产品添加到购物车中时,更新或删除产品,然后运行代码获取最新的购物车项目,我得到的结果错误,这意味着获取上一步的结果。e、 g

将产品添加到购物车中,在获取购物车项目后,我将以空数组获取项目,在下一次调用获取购物车时,我将获取正确的记录

更新产品数量,然后get cart返回以前的商品数量,因此,如果我有一个产品,并且它在cart中的数量为1,并且我更新了数量,我在cart中仍然得到1,在第二次调用get cart时,我得到了正确的数量

从购物车中删除商品也是如此

这是我正在使用的代码

1。创建新购物车

 $store = Mage::app()->getStore();
    $stroeId = $store->getId();
    $quote = Mage::getModel('sales/quote');
    $quote->setStoreId($stroeId)
                ->setIsActive(true)
                ->setIsMultiShipping(false)
                ->save();
    $quote->getBillingAddress();
    $quote->getShippingAddress()->setCollectShippingRates(true);
    $quote->collectTotals();
    $quote->save();
    $quoteId = $quote->getId();
$products = array(array(
    'product_id' => $productId,
    'qty' => $qty,
    'options' => null,
    'super_attribute' => $custom_options,
    'bundle_option' => null,
    'bundle_option_qty' => null,
    'links' => null
));
$productMdl = Mage::getSingleton('myextension/product');
$result = $productMdl->add($quoteId, $products);
//This is the code for getting cart data
$apiMdl = Mage::getSingleton('myextension/api');
$result = $apiMdl->info($quoteId,Mage::app()->getStore()->getId());
$data = (array)$result;
2。添加到购物车并立即添加到购物车后

 $store = Mage::app()->getStore();
    $stroeId = $store->getId();
    $quote = Mage::getModel('sales/quote');
    $quote->setStoreId($stroeId)
                ->setIsActive(true)
                ->setIsMultiShipping(false)
                ->save();
    $quote->getBillingAddress();
    $quote->getShippingAddress()->setCollectShippingRates(true);
    $quote->collectTotals();
    $quote->save();
    $quoteId = $quote->getId();
$products = array(array(
    'product_id' => $productId,
    'qty' => $qty,
    'options' => null,
    'super_attribute' => $custom_options,
    'bundle_option' => null,
    'bundle_option_qty' => null,
    'links' => null
));
$productMdl = Mage::getSingleton('myextension/product');
$result = $productMdl->add($quoteId, $products);
//This is the code for getting cart data
$apiMdl = Mage::getSingleton('myextension/api');
$result = $apiMdl->info($quoteId,Mage::app()->getStore()->getId());
$data = (array)$result;
我正在调用模型中的基本MagentoAPI模型,以便将MagentoAPI的默认功能用于这些操作

请给我建议解决这个问题的办法

谢谢