我正在尝试覆盖catalogProductInfo
. 我要做的就是为返回的肥皂结果添加另一个属性。问题是我的新属性没有显示。这是我迄今为止尝试解决的问题。
- 我试图进入 php.ini 文件并
soap.wsdl_cache_enabled=1
关闭soap.wsdl_cache = 1
- 我尝试进入 /tmp/ 文件夹并删除 wsdl 缓存文件
- 我禁用了magento缓存并尝试重新索引
我正在尝试覆盖以下 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>
在下面的代码中,我尝试添加associated
基本的产品数据。我这样做只是为了简单地看看它是否出现。问题是当我拨打肥皂电话时。它不会出现在返回的结果中。我的模块已成功覆盖Mage_Catalog_Model_Product_Api_V2
,因为我可以在我的模块中破坏它。
/app/code/local/Namespace/ImportExport/Model/Product/Api/V2.php
命名空间_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;
}
}
我什至尝试associated
在catalogProductReturnEntity
模块目录 wsdl.xml 文件 /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 缓存。我究竟做错了什么 ??
[更新]尽管如此,没有任何改变。该属性associated
是我正在寻找的那个。我在星期五发了这篇文章。接下来的星期一我试了一下,相关的属性突然出现了。现在有一个新问题。我正在尝试添加一个新属性,但遇到了同样的问题。有什么建议么 ??