Attribute model
(eav_attribute
テーブル)からMagentoでattribute_code
を取得するにはどうすればよいですか?
Notice:
- 私はentity_typeを気にしません。
ありがとうございます。Magentoの属性コードで属性モデルを取得
19
A
答えて
50
異なるエンティティに同じattribute_code
を割り当てることができるので、entity_type
を知る必要があります。だから、属性モデルを取得する:
$attributeModel = Mage::getModel('eav/entity_attribute')->loadByCode($entity_type, $attributeCode);
$entity_type
パラメータがnumeric
(直接ID)、string
(例えば、'catalog_product'
またはMage_Catalog_Model_Product::ENTITY
の場合)であることも、モデルMage_Eav_Model_Entity_Type
0
$ attributeModel =メイジ:: getModelのインスタンスであることができます( 'eav/entity_attribute') - > loadByCode(1、 'is_approved'); echo $ attributeModel-> getAttributeId();
+0
これは、多くのシナリオのうちの1つにのみ固有のデータを持つばかりでなく、受け入れられた回答をエコーします。コードはフォーマットされておらず、説明もありません。 –
3
おそらく、あなたは私がコードによって製品から属性を必要とするので、私はこのようにそれを行うコレクション
Mage::getModel('eav/entity_attribute')->getCollection()->addFieldToFilter('attribute_code', array('in' => $codes))
フィルタによって属性を読み取ることができます。
$codes = (array) $codes;
$res = array_intersect_key($this->getAttributes(), array_flip($codes));
$コードがattribute_codeです-array 範囲:拡張Mage_Catalog_Model_Product
3
$attribute_code = "flat_printing_quantity";
$attribute_details =
Mage::getSingleton("eav/config")->getAttribute(Mage_Catalog_Model_Product::ENTITY, $attribute_code);
$attribute = $attribute_details->getData();
echo $attribute['attribute_id'];
関連する問題
- 1. カスタム属性コードで属性ラベル/オプションを取得magento
- 2. 属性値を取得 - Magento
- 3. Magento属性値
- 4. magento属性のPHPコードを翻訳
- 5. Magentoのバックエンドアドレス属性
- 6. タイトルのMagento属性
- 7. Magentoの、ユーザー属性
- 8. HTML属性へのMVCモデル属性
- 9. Magento 2.0で属性コードを使用して製品属性オプションを取得する方法
- 10. Backbone.jsモデルの従属属性
- 11. MagentoカスタムオプションVS属性
- 12. Magento - 属性別フィルタ
- 13. モデル属性が
- 14. id属性で別の属性を取得するXPath
- 15. Magento:属性セットから属性をプログラムで削除する
- 16. Magento属性と属性セットをプログラムで追加する
- 17. すべての製品属性のリストをmagentoで取得
- 18. Rails:XMLのモデル属性
- 19. クラスの属性を取得
- 20. Magento - 外部PHPスクリプトで商品のカスタム属性値を取得
- 21. Magento 2でフロントエンドの属性リストを取得するには
- 22. Yii2 //モデルのモデルの属性
- 23. C#Xelement属性値を属性名で取得する
- 24. Magentoのカスタム属性がYES
- 25. Magentoカスタム属性へのアクセス
- 26. キーチェーンアイテムの属性の取得
- 27. Magento 1.6 Soap v2の属性と追加の属性
- 28. 倉庫属性モデル
- 29. Woocommerceバリエーション属性を取得
- 30. htmlagilitypackフォームアクション属性を取得
ありがとうございます。私はあなたに結果を確認しようとします。 – vietean
上記のコードを使用して、short_descriptionが 'フロントエンドのプロダクトビューページに表示されているかどうか'を確認してください: $ attributeShortDescription = Mage :: getModel( 'eav/entity_attribute') - > loadByCode( 'catalog_product'、 'short_description '); $ attributeShortDescription-> getIsVisibleOnFront(); –
定数を使用するバージョン: $ _attr = Mage :: getModel( 'eav/entity_attribute') - > loadByCode(Mage_Catalog_Model_Product :: ENTITY、$ attributeCode); –