cancel
Showing results for 
Search instead for 
Did you mean: 

Get list of products with price and special price by category - SOAP Magento

Get list of products with price and special price by category - SOAP Magento

I'm trying to find a way to call Magento with SOAP v1 and return a list of products with the price and special price of the same category but every function I found doesn't return this values, I would need to make a call for each product and it takes a long time.

 

Until now I tried:

$category = $client->call($session, 'catalog_category.assignedProducts', '31');


and:

$category = $client->call($session, 'catalog_product.list');


Is there a way?

2 REPLIES 2

Re: Get list of products with price and special price by category - SOAP Magento

you have to extend the api method in Mage_Catalog_Model_Category_Api

 

    public function assignedProducts($categoryId, $store = null)
    {
        $category = $this->_initCategory($categoryId);

        $storeId = $this->_getStoreId($store);
        $collection = $category->setStoreId($storeId)->getProductCollection()->addAttributeToSelect(array('price', 'special_price'));
        ($storeId == 0)? $collection->addOrder('position', 'asc') : $collection->setOrder('position', 'asc');;

        $result = array();

        foreach ($collection as $product) {
            $result[] = array(
                'product_id' => $product->getId(),
                'type'       => $product->getTypeId(),
                'set'        => $product->getAttributeSetId(),
                'sku'        => $product->getSku(),
                'position'   => $product->getCatIndexPosition(),
                'price'      => $product->getPrice(),
                'special_price'  => $product->getSepcialPrice()
            );
        }

        return $result;
    }

and then modify wsdl.xml in catalog module

 

 

            <complexType name="catalogAssignedProduct">
                <all>
                    <element name="product_id" type="xsd:int"/>
                    <element name="type" type="xsd:string"/>
                    <element name="set" type="xsd:int"/>
                    <element name="sku" type="xsd:string"/>
                    <element name="position" type="xsd:int"/>
                    <element name="price" type="xsd:decimal" />
                    <element name="special_price" type="xsd:decimal" />
                </all>
            </complexType>

 

 

Re: Get list of products with price and special price by category - SOAP Magento

hi, it can add grouprice to $collection in array?, thanks