我试图覆盖catalogProductInfo.我要做的就是为返回的soap结果添加另一个属性.问题是我的新属性没有显示.这是我迄今为止尝试解决这个问题的方法.
>我试图进入php.ini文件并关闭soap.wsdl_cache_enabled = 1和soap.wsdl_cache = 1
>我尝试进入/ tmp /文件夹并删除wsdl缓存文件
>我禁用了magento缓存,我尝试了reindex
我试图覆盖magento产品信息api模型V2,其中包括以下内容……
http://www.magentocommerce.com/api/soap/catalog/catalogProduct/catalog_product.info.html
我正在使用v2,这是以下示例.我想要做的是为返回的结果添加另一个属性
$prodInfo = $fclient->catalogProductInfo($fsession, $prod->product_id, null,$attributes);
这就是我尝试覆盖返回的内容…我首先创建了我的模块.这是我的配置文件
/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>
在下面的代码中,我尝试在基本产品数据中添加关联.我这样做只是为了看看它是否显示出来.问题是我打肥皂的时候.它没有出现在返回的结果中.我的模块已经成功覆盖了Mage_Catalog_Model_Product_Api_V2,因为我可以在我的模块中打破它.
/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;
}
}
我甚至尝试在模块目录wsdl.xml文件中添加与catalogProductReturnEntity关联的内容
/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>
我什么都没得到.我关掉了肥皂缓存.我关闭了所有magento缓存.我究竟做错了什么 ??
[更新]
尽管如此,没有任何改变.关联的属性是我正在寻找的属性.我星期五发了这个帖子.接下来的星期一,我试了一下,关联的属性显示在没有的地方.现在有一个新问题.我试图添加一个新属性,但得到相同的问题.有什么建议 ??
最佳答案 弄清楚了. Php Soap有一个Server和Client类.因此,您必须确保清除soap请求者的缓存和响应.换句话说,使用soap调用的服务器,找到缓存并清除它,以及接收缓存调用的服务器也是清除的.必须清除两者才能获得完整更新.不只是肥皂服务器.