我有我的自定義產品屬性在magento.i想要設置產品描述的動態。他們任何方式在magento,以便我們可以找到屬性是由我們自定義創建默認magento。區分magento產品屬性和自定義創建的產品屬性
我已經搜索過,但沒有取得任何成功。
請幫忙。
在此先感謝。
我有我的自定義產品屬性在magento.i想要設置產品描述的動態。他們任何方式在magento,以便我們可以找到屬性是由我們自定義創建默認magento。區分magento產品屬性和自定義創建的產品屬性
我已經搜索過,但沒有取得任何成功。
請幫忙。
在此先感謝。
假設您有一個代碼爲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
}
您可以使用Magento的默認API來獲取默認的產品列表
欲瞭解更多詳細信息,您可以參考以下網址:
使用將代碼:
$proxy = new SoapClient('localhost/api/soap/?wsdl');
$sessionId = $proxy->login('apiUser', 'apiKey');
$listAttributes = $proxy->call($sessionId, 'product.listOfAdditionalAttributes', array('simple', 13));
請註明相關的答案,而不僅僅是一個鏈接。多年以後,鏈接可能會破裂。 – mhlester
使用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
)
);
我希望這將解決您的問題..
感謝您的解決方案爲我工作。只需一個小修改 D應該是$ attribute-> getIsUserdefined() 的資本,它將是$ attribute-> getIsUserDefined() –
@waqarmirza。對。對不起。我修好了它。 – Marius
好的沒問題。感謝解決方案 –