Get price in cart_product.list API magento
To add extra feilds in cart_product.list api
path : app\code\core\Mage\Checkout\Model\Cart\Product\Api.php
public function items($quoteId, $store = null)
{
$quote = $this->_getQuote($quoteId, $store);
if (empty($store)) {
$store = $quote->getStoreId();
}
if (!$quote->getItemsCount()) {
return array();
}
$productsResult = array();
foreach ($quote->getAllItems() as $item) {
/** @var $item Mage_Sales_Model_Quote_Item */
$product = $item->getProduct();
if(($product->getSpecialPrice())!=null){
$final_price= $product->getSpecialPrice();
}else{
$final_price= $product->getPrice();
}
$product_amount = ($final_price * $item->getQty());
$grandTotal += $final_price*$item->getQty();
$productsResult[] = array( // Basic product data
'product_id' => $product->getId(),
'sku' => $product->getSku(),
'name' => $product->getName(),
'price' => $product->getPrice(),
'specialPrice' => $product->getSpecialPrice(),
'qty' => $item->getQty(),
'image' => (string) Mage::helper('catalog/image')->init($product, 'thumbnail')->resize(265,265)->keepFrame(FALSE),
'amout' => $product_amount,
'grand total' => $grandTotal,
'itemsinStock' => $product->getStockItem()->getQty(),
'set' => $product->getAttributeSetId(),
'type' => $product->getTypeId(),
'category_ids' => $product->getCategoryIds(),
'website_ids' => $product->getWebsiteIds()
);
}
return $productsResult;
}
No comments:
Post a Comment