简体   繁体   中英

magento soap catalogInventoryStockItemList by custom product attribute

I am trying to retrieve the stock amount of a product by a product custom attribute. Currently I can retrieve the stock amount by using the product ID instead of the costum attribute by using

$result = $proxy->catalogInventoryStockItemList($sessionId, array('108906', '2'));
var_dump($result);

But how do I retrieve this by a costum attribute?

You may start with this. To be able to achieve including Custom Attribute , you would want to override the below files:

app/code/core/Mage/CatalogInventory/etc/wsdl.xml

Override this as - app/code/local/Namespace/Modulename/etc/wsdl.xml to include your custom attribute:

Line no: 56

<message name="catalogInventoryStockItemListRequest">
    <part name="sessionId" type="xsd:string" />
    <part name="products" type="typens:ArrayOfString" />
    <part name="customAttribute" type="xsd:string" />
</message>

app/code/core/Mage/CatalogInventory/etc/wsi.xml

Override this as - app/code/local/Namespace/Modulename/etc/wsi.xml to include your custom attribute:

Line no: 55

        <xsd:element name="catalogInventoryStockItemListRequestParam">
            <xsd:complexType>
                <xsd:sequence>
                    <xsd:element minOccurs="1" maxOccurs="1" name="sessionId" type="xsd:string" />
                    <xsd:element minOccurs="1" maxOccurs="1" name="productIds" type="typens:ArrayOfString" />
                    <xsd:element minOccurs="1" maxOccurs="1" name="customAttribute" type="xsd:string" />
                </xsd:sequence>
            </xsd:complexType>
        </xsd:element>

Then you can try your code as below:

$result = $proxy->catalogInventoryStockItemList($sessionId, array('108906', '2'), 'custom_attribute_code');
var_dump($result);

I have NOT tried this in my machine. However, this can be a start for you.

Happy Coding...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM