Hi,
When I call the webservice catalogInventoryStockItemList to get the stock information on a specific product, I receive this answer:
<SOAP-ENV:Envelope xmlnsOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:Magento">
<SOAP-ENV:Body>
<ns1:catalogInventoryStockItemListResponseParam>
<result>
<complexObjectArray>
<product_id>41714</product_id>
<sku>42209</sku>
<qty>9.0000</qty>
<is_in_stock>1</is_in_stock>
</complexObjectArray>
</result>
</ns1:catalogInventoryStockItemListResponseParam>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
I need to get the backorders value of this product but it is absent from XML.
I did modify 3 files inside the Magento API:
<complexType name="catalogInventoryStockItemEntity">
<all>
<element name="product_id" type="xsd:string" minOccurs="0" />
<element name="sku" type="xsd:string" minOccurs="0" />
<element name="qty" type="xsd:string" minOccurs="0" />
<element name="backorders" type="xsd:string" minOccurs="0" />
<element name="is_in_stock" type="xsd:string" minOccurs="0" />
</all>
</complexType>
<xsd:complexType name="catalogInventoryStockItemEntity">
<xsd:sequence>
<xsd:element name="product_id" type="xsd:string" minOccurs="0" />
<xsd:element name="sku" type="xsd:string" minOccurs="0" />
<xsd:element name="qty" type="xsd:string" minOccurs="0" />
<xsd:element name="backorders" type="xsd:string" minOccurs="0" />
<xsd:element name="is_in_stock" type="xsd:string" minOccurs="0" />
</xsd:sequence>
</xsd:complexType>
public function items($productIds)
{
if (!is_array($productIds)) {
$productIds = array($productIds);
}
$product = Mage::getModel('catalog/product');
foreach ($productIds as &$productId) {
if ($newId = $product->getIdBySku($productId)) {
$productId = $newId;
}
}
$collection = Mage::getModel('catalog/product')
->getCollection()
->setFlag('require_stock_items', true)
->addFieldToFilter('entity_id', array('in'=>$productIds));
$result = array();
foreach ($collection as $product) {
if ($product->getStockItem()) {
$result[] = array(
'product_id' => $product->getId(),
'sku' => $product->getSku(),
'qty' => $product->getStockItem()->getQty(),
'backorders' => $product->getStockItem()->getBackorders(),
'is_in_stock' => $product->getStockItem()->getIsInStock()
);
}
}
return $result;
}
After those 3 changes and purging the cache, the response is still the same.
How can I get this value??
Regards,
Bernard
Solved! Go to Solution.
Finally it was just a problem of cache.
After purging the cache, backorders information was visible in the XML response.
I have facing problem with backorders if we create order from admin panel .
backorders not work in simply test magento of any version