访问magento';使用RESTAPI的s签出/购物车
我正在尝试为我的rest客户端集成购物车同步解决方案。 目标应该是无论我从哪里访问我的商店,我都可以拥有相同的购物车 因此,我必须首先使用经过身份验证的api用户将现有项目交付给客户机 但我一开始就被卡住了:访问magento';使用RESTAPI的s签出/购物车,api,rest,checkout,magento-1.7,Api,Rest,Checkout,Magento 1.7,我正在尝试为我的rest客户端集成购物车同步解决方案。 目标应该是无论我从哪里访问我的商店,我都可以拥有相同的购物车 因此,我必须首先使用经过身份验证的api用户将现有项目交付给客户机 但我一开始就被卡住了: protected function _retrieveCollection() { $cart = Mage::getSingleton('checkout/cart')->getQuote(); $cart->setCustomerId($this->
protected function _retrieveCollection()
{
$cart = Mage::getSingleton('checkout/cart')->getQuote();
$cart->setCustomerId($this->getApiUser()->getUserId());
$cart->setStoreId(4);
$cart->load();
return $cart->getAllItems();
}
返回空数组,即使我的购物车中有产品
有什么提示吗?有那种感觉我完全站错一边了…找到了解决办法。通过客户获取报价(另一种方式)效果很好:
Mage::app()->setCurrentStore(4);
$cart = Mage::getModel('sales/quote')->loadByCustomer($this->getApiUser()->getUserId());
$items = array();
foreach ($cart->getAllVisibleItems() as $key => $item) {
$items[] = array(
'name' => $item->getName(),
'entity_id' => $item->getProductId(),
'description' => $item->getDescription(),
'final_price_with_tax' => $item->getBasePriceInclTax(),
'qty' => $item->getQty()
);
}
可以使用REST结账吗?因为我问了一个关于REST的问题,所以我得到的答案是我们不能使用REST访问签出和其他东西@vsvankhede他正在开发rest api,但没有使用。axel您的答案是正确的,工作起来很有魅力,但当我尝试在函数末尾返回$items时,它只显示每个项的“数量”,但如果是echo,则显示全部。我想要这个json响应,但由于返回而被困在这里。