Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
访问magento';使用RESTAPI的s签出/购物车_Api_Rest_Checkout_Magento 1.7 - Fatal编程技术网

访问magento';使用RESTAPI的s签出/购物车

访问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->

我正在尝试为我的rest客户端集成购物车同步解决方案。 目标应该是无论我从哪里访问我的商店,我都可以拥有相同的购物车

因此,我必须首先使用经过身份验证的api用户将现有项目交付给客户机

但我一开始就被卡住了:

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响应,但由于返回而被困在这里。