2014-01-21 78 views

回答

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 
} 
+0

感谢您的解决方案为我工作。只需一个小修改 D应该是$ attribute-> getIsUserdefined() 的资本,它将是$ attribute-> getIsUserDefined() –

+0

@waqarmirza。对。对不起。我修好了它。 – Marius

+0

好的没问题。感谢解决方案 –

0

您可以使用Magento的默认API来获取默认的产品列表

欲了解更多详细信息,您可以参考以下网址:

使用将

http://www.magentocommerce.com/api/soap/catalog/catalogProduct/catalog_product.listOfAdditionalAttributes.html

代码:

$proxy = new SoapClient('localhost/api/soap/?wsdl'); 
$sessionId = $proxy->login('apiUser', 'apiKey'); 
$listAttributes = $proxy->call($sessionId, 'product.listOfAdditionalAttributes', array('simple', 13)); 
+0

请注明相关的答案,而不仅仅是一个链接。多年以后,链接可能会破裂。 – mhlester

1

使用Magento的SOAP/REST API用于创建产品,并与价值观的更新以及自定义属性,

$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 
) 
); 

我希望这将解决您的问题..