I need to get all products that are at a discount. Is there any way to achieve this with SOAP API? Is it possible to compose such a filter?
1 Answer
Try below code : You need to write custom api to get your desired output:
public function getProductDetailsByprice( )
{
$store_id = 1; // Use the default store
$collection = Mage::getModel('catalog/product')->getCollection()
->addStoreFilter($this->_getStoreId($$store_id)) ;
$result = array();
foreach ($collection as $product) {
$original_price = $product->getData('price');
$discounted_price = Mage::getResourceModel('catalogrule/rule')->getRulePrice(
Mage::app()->getLocale()->storeTimeStamp($store_id),
Mage::app()->getStore($store_id)->getWebsiteId(),
Mage::getSingleton('customer/session')->getCustomerGroupId(),
$product->getId());
if ($discounted_price != $original_price)
{
$result[] = array(
'product_id' => $product->getId() ,
'type' => $product->getTypeId(),
'set' => $product->getAttributeSetId(),
'sku' => $product->getSku(),
'position' => $product->getCatIndexPosition(),
'brand' => $product->getData('brand'),
'price' => $discounted_price,
'name' => $product->getData('name'),
'original_price' => $original_price
);
}
}
return $result;
}