我在magento中有我的自定义产品属性。我想动态设置产品描述。它们是magento的任何方式,以便我们可以找到属性是由我们自定义创建的,而不是默认的magento。
我曾经搜查过但没有取得任何成功。
请帮助。
先谢谢。
答案 0 :(得分:3)
假设您有一个代码为some_code
的属性
以下是如何检查它是系统属性还是自定义属性的方法。
$attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', 'some_code');
if ($attribute->getIsUserDefined()) {
//then you created the attribute
}
else {
//then it's a system attribute
}
答案 1 :(得分:1)
使用magento soap / rest api为Product创建自定义属性并使用值进行更新,
$proxy = new SoapClient('http://magentohost/api/soap/?wsdl');
$sessionId = $proxy->login('apiUser', 'apiKey');
echo "<pre>";
// Create new attribute
$attributeToCreate = array(
"attribute_code" => "new_attribute",
"scope" => "store",
"frontend_input" => "select",
"is_unique" => 0,
"is_required" => 0,
"is_configurable" => 0,
"is_searchable" => 0,
"is_visible_in_advanced_search" => 0,
"used_in_product_listing" => 0,
"additional_fields" => array(
"is_filterable" => 1,
"is_filterable_in_search" => 1,
"position" => 1,
"used_for_sort_by" => 1
),
"frontend_label" => array(
array( "store_id" => 0,"label" => "A new attribute" )
)
);
$attributeId = $proxy->call($sessionId,"product_attribute.create",
array(
$attributeToCreate
)
);
// Update attribute
$attributeToUpdate = array(
"scope" => "global",
"is_unique" => 1,
"is_required" => 1,
"is_configurable" => 1,
"is_searchable" => 1,
"is_visible_in_advanced_search" => 0,
"used_in_product_listing" => 0,
"additional_fields" => array(
"is_filterable" => 01,
"is_filterable_in_search" => 0,
"position" => 2,
"used_for_sort_by" => 0
),
"frontend_label" => array(
array(
"store_id" => 0,
"label" => "A Test Attribute"
)
)
);
$proxy->call(
$sessionId,
"product_attribute.update",
array(
"new_attribute",
$attributeToUpdate
)
);
我希望这能解决你的问题。
答案 2 :(得分:0)
您可以使用Magento默认API获取默认产品列表
有关详细信息,请参阅以下网址:
使用的代码将是:
$proxy = new SoapClient('localhost/api/soap/?wsdl');
$sessionId = $proxy->login('apiUser', 'apiKey');
$listAttributes = $proxy->call($sessionId, 'product.listOfAdditionalAttributes', array( 'simple', 13 ));