0

I need to show small image of product on cart page.Cart info is not giving any information for image of product. So I have tried overriding cart.info method.

My config.xml(/etc/config.xml) is like:

 <?xml version="1.0"?>
 <config>
<modules>
    <Customsoapcart_Checkoutsoap>
        <version>0.1.0</version>
    </Customsoapcart_Checkoutsoap>
</modules>
<global>
    <models>
        <customsoapcart_checkoutsoap>
            <class>Customsoapcart_Checkoutsoap_Model</class>
        </customsoapcart_checkoutsoap>
        <checkout>
            <rewrite>
                <cart_product_api_v2>Customsoapcart_Checkoutsoap_Model_Checkout_Cart_Product_Api_V2</cart_product_api_v2>
            </rewrite>
        </checkout>
    </models>
    <helpers>
        <customsoapcart_checkoutsoap>
            <class>Customsoapcart_Checkoutsoap_Helper</class>
        </customsoapcart_checkoutsoap>
    </helpers>
</global>
</config>

My wsdl.xml(/etc/wsdl.xml) is like:

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns:typens="urn:{{var wsdl.name}}" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
         xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
         xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
         xmlns="http://schemas.xmlsoap.org/wsdl/"
         name="{{var wsdl.name}}" targetNamespace="urn:{{var wsdl.name}}">
<types>
    <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:Magento">
        <import namespace="http://schemas.xmlsoap.org/soap/encoding/"
    schemaLocation="http://schemas.xmlsoap.org/soap/encoding/"/>
        <complexType name="shoppingCartProductEntity">
            <all>
                <element name="small_image" type="xsd:string" minOccurs="0"/>
            </all>
        </complexType>

    </schema>
</types>
</definitions>

My V2.php file (/namespacename/modulename/Model/Checkout/Cart/Product/Api/V2.php) is like:

<?php
class Customsoapcart_Checkoutsoap_Model_Checkout_Cart_Product_Api_V2 extends Mage_Checkout_Model_Cart_Product_Api_V2
{
/**
* Retrieve full order information
*
* @param string $orderIncrementId
*
* @return array
*/

public function items($quoteId, $store = null)
{
$productsResult = parent::items($quoteId, $store = null);
$productsResult['image']='image';
    return $productsResult;
}
}

Now when I call my web service in my script:

 $proxy = new SoapClient('http://magentohost/api/v2_soap/?wsdl', array('trace' => 1, 'cache_wsdl' => 0)); // TODO : change url
$sessionId = $proxy->login('username', 'apikey'); // TODO : change login and pwd if necessary

$result = $proxy->shoppingCartInfo($sessionId, '320');
echo '<pre>';print_r($result);

I am not getting extra field image in the result. I think something is wrong with wsdl.xml which I am missing something in wsdl.xml but cant able to figure out it.

0

I have figured out another way to solve the problem. I have made custom module in rest api for giving cart information.Web service will take quote_id as parameter and it will return cart information in reponse.

For example: My web service request is http://magentohost/api/rest/cartcollection/:cart_id

$cartId = $this->getRequest()->getParam('cart_id');
    $quoteCollection = Mage::getModel('sales/quote_item')->getCollection();
    $quoteCollection->addFieldToFilter('quote_id', $cartId);

Then it will fetch information from sales/quote_item table and return the collection of quote.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.