I am trying to override catalogProductInfo
. All I am trying to do is add another attribute to the returning soap result. The problem is my new attribute is not showing. This is what I've tried so far to fix the issue.
- I tried to go into the php.ini file and turning off
soap.wsdl_cache_enabled=1
andsoap.wsdl_cache = 1
- I tried going into /tmp/ folder and deleting the wsdl cache file
- I disabled magento cacheing and I tried reindex
I am trying to override the magento product info api model V2 which is the following...
http://www.magentocommerce.com/api/soap/catalog/catalogProduct/catalog_product.info.html
I am using v2 which is the following example. What I want to do is add another attribute to the returning result
$prodInfo = $fclient->catalogProductInfo($fsession, $prod->product_id, null,$attributes);
This is what I did to try to override what is returned... I first created my module. Here is my config file /app/code/local/Namespace/ImportExport/etc/config.xml
<config>
<modules>
<Namespace_ImportExport>
<version>0.0.1</version>
</Namespace_ImportExport>
</modules>
<global>
<models>
<catalog>
<rewrite>
<product_api_v2>Namespace_ImportExport_Model_Product_Api_V2</product_api_v2>
</rewrite>
</catalog>
</models>
</global>
</config>
In the below code, I try to add associated
in the basic product data. I am doing this just to simply see if it shows up. The problem is when I make a soap call. It does not show up in the returning results. My module has successfully overrided Mage_Catalog_Model_Product_Api_V2
because I can break it within my module.
/app/code/local/Namespace/ImportExport/Model/Product/Api/V2.php
Namespace_ImportExport_Model_Product_Api_V2
<?php
class Namespace_ImportExport_Model_Product_Api_V2
extends Mage_Catalog_Model_Product_Api_V2
{
/**
* Retrieve product info
*
* @param int|string $productId
* @param string|int $store
* @param stdClass $attributes
* @return array
*/
public function info($productId, $store = null, $attributes = null, $identifierType = null)
{
$product = $this->_getProduct($productId, $store, $identifierType);
if (!$product->getId()) {
$this->_fault('not_exists');
}
$result = array( // Basic product data
'associated' =>"test",
'product_id' => $product->getId(),
'sku' => $product->getSku(),
'set' => $product->getAttributeSetId(),
'type' => $product->getTypeId(),
'categories' => $product->getCategoryIds(),
'websites' => $product->getWebsiteIds(),
);
if($product->getTypeId() == "configurable") {
Mage::log($product);
// $child_products = $product->getTypeInstance(true)->getAssociatedProducts($product);
// if(!empty($child_products)) {
// $result['associated_products'] = "";
// foreach ($child_products as $p) {
// $result['associated_products'] .= $p->getData('sku').",";
// }
// }
}
$allAttributes = array();
if (isset($attributes->attributes)) {
$allAttributes += array_merge($allAttributes, $attributes->attributes);
}
$_additionalAttributeCodes = array();
if (isset($attributes->additional_attributes)) {
foreach ($attributes->additional_attributes as $k => $_attributeCode) {
$allAttributes[] = $_attributeCode;
$_additionalAttributeCodes[] = $_attributeCode;
}
}
$_additionalAttribute = 0;
foreach ($product->getTypeInstance(true)->getEditableAttributes($product) as $attribute) {
if ($this->_isAllowedAttribute($attribute, $allAttributes)) {
if (in_array($attribute->getAttributeCode(), $_additionalAttributeCodes)) {
$result['additional_attributes'][$_additionalAttribute]['key'] = $attribute->getAttributeCode();
$result['additional_attributes'][$_additionalAttribute]['value'] = $product->getData($attribute->getAttributeCode());
$_additionalAttribute++;
} else {
$result[$attribute->getAttributeCode()] = $product->getData($attribute->getAttributeCode());
}
}
}
return $result;
}
}
I have even tried adding associated
to catalogProductReturnEntity
within the module catalog wsdl.xml file
/app/code/core/Mage/Catalog/etc/wsdl.xml
<complexType name="catalogProductReturnEntity">
<all>
<element name="associated" type="xsd:string" minOccurs="0" />
<element name="product_id" type="xsd:string" minOccurs="0" />
<element name="sku" type="xsd:string" minOccurs="0" />
<element name="set" type="xsd:string" minOccurs="0" />
<element name="type" type="xsd:string" minOccurs="0" />
<element name="categories" type="typens:ArrayOfString" minOccurs="0" />
<element name="websites" type="typens:ArrayOfString" minOccurs="0" />
<element name="created_at" type="xsd:string" minOccurs="0" />
<element name="updated_at" type="xsd:string" minOccurs="0" />
<element name="type_id" type="xsd:string" minOccurs="0" />
<element name="name" type="xsd:string" minOccurs="0" />
<element name="description" type="xsd:string" minOccurs="0" />
<element name="short_description" type="xsd:string" minOccurs="0" />
<element name="weight" type="xsd:string" minOccurs="0" />
<element name="status" type="xsd:string" minOccurs="0" />
<element name="url_key" type="xsd:string" minOccurs="0" />
<element name="url_path" type="xsd:string" minOccurs="0" />
<element name="visibility" type="xsd:string" minOccurs="0" />
<element name="category_ids" type="typens:ArrayOfString" minOccurs="0" />
<element name="website_ids" type="typens:ArrayOfString" minOccurs="0" />
<element name="has_options" type="xsd:string" minOccurs="0" />
<element name="gift_message_available" type="xsd:string" minOccurs="0" />
<element name="price" type="xsd:string" minOccurs="0" />
<element name="special_price" type="xsd:string" minOccurs="0" />
<element name="special_from_date" type="xsd:string" minOccurs="0" />
<element name="special_to_date" type="xsd:string" minOccurs="0" />
<element name="tax_class_id" type="xsd:string" minOccurs="0" />
<element name="tier_price" type="typens:ArrayOfString" minOccurs="0" />
<element name="meta_title" type="xsd:string" minOccurs="0" />
<element name="meta_keyword" type="xsd:string" minOccurs="0" />
<element name="meta_description" type="xsd:string" minOccurs="0" />
<element name="custom_design" type="xsd:string" minOccurs="0" />
<element name="custom_layout_update" type="xsd:string" minOccurs="0" />
<element name="options_container" type="xsd:string" minOccurs="0" />
<element name="additional_attributes" type="typens:associativeArray" minOccurs="0" />
</all>
</complexType>
Still I get nothing. I have soap cacheing turned off. I have all magento cacheing turned off. What am I doing wrong ??
[Update]
Despite all of this, nothing changes. the attribute associated
is the one I am looking for. I made this post on a friday. The following monday I tried it out and the associated attribute show up out of no where. There is a new problem now. I am trying to add a new attribute but getting the same issue. Any suggestions ??