I have created custom attribute Barcode. Each simple product has filled unique barcode value.
Where and what should I change to display it for each order items in output of method salesOrderInfo
?
I have Magento ver. 1.9.0.1
This problem can be solved by creating module.
Module files:
app/code/local/YourCompany/Sales/etc/config.xml - module config file
copy app/code/core/Mage/Sales/etc/wsi.xml to app/code/local/YourCompany/Sales/etc/wsi.xml and add your new fields
copy app/code/core/Mage/Sales/etc/wsdl.xml to app/code/local/YourCompany/Sales/etc/wsdl.xml and add your new fields
app/code/local/YourCompany/Sales/Model/Order/Api.php - in my example
I'm adding custom fields: upc, style, color and size
<?php
class YourCompany_Sales_Model_Order_Api extends Mage_Sales_Model_Order_Api{
protected function _getAttributes($object, $type, array $attributes = null){
$result = parent::_getAttributes($object, $type, $attributes);
if( $type === 'order_item' ){
$result['upc'] = $object->getProduct()->getData('barcode');
$parent = Mage::getResourceSingleton('catalog/product_type_configurable')
->getParentIdsByChild($object->getProduct()->getData('entity_id'));
if( $parent ) $parent = Mage::getModel('catalog/product')->load($parent[0]);
$result['style'] = $parent ? $parent->getData('name') : '';
$result['color'] = $object->getProduct()->getAttributeText('color');
$result['size'] = $object->getProduct()->getAttributeText('size');
}elseif( $type === 'order_address' ){
if( $object->getData('country_id') !== 'US' ){
$region = Mage::getModel('directory/region')->load($object->getData('region_id'));
if( $region ) $result['region'] = $region->getCode();
$country = Mage::getModel('directory/country')->loadByCode($object->getData('country_id'));
if( $country ) $result['country_id'] = $country->getName();
}
}
return $result;
}
}