Come ho potuto ottenere Attribute model
(da: eav_attribute
tabella) da attribute_code
in Magento?
Avviso:
- Non mi interessa cosa sia entity_type.
Grazie mille.Get Attribute modello da attribute_code in Magento
risposta
Devi conoscere entity_type
perché puoi avere lo stesso attribute_code
per diverse entità. Quindi, per ottenere attribuire modello:
$attributeModel = Mage::getModel('eav/entity_attribute')->loadByCode($entity_type, $attributeCode);
$entity_type
parametro può essere numeric
(id direttamente), string
(ad esempio 'catalog_product'
o Mage_Catalog_Model_Product::ENTITY
) oppure può essere un'istanza di modello Mage_Eav_Model_Entity_Type
$ attributeModel = Mage :: getModel ('eav/entity_attribute') -> loadByCode (1, 'is_approved'); echo $ attributeModel-> getAttributeId();
Non solo dispone di dati specifici per uno solo dei numerosi scenari, ma rispecchia anche la risposta accettata, il codice non è formattato e non vi sono spiegazioni. –
Forse si può leggere gli attributi di filtro della collezione
Mage::getModel('eav/entity_attribute')->getCollection()->addFieldToFilter('attribute_code', array('in' => $codes))
Da quando ho bisogno gli attributi dal Prodotto da codice, lo faccio in questo modo:
$codes = (array) $codes;
$res = array_intersect_key($this->getAttributes(), array_flip($codes));
$ codici è un attribute_code -array Scopo: esteso Mage_Catalog_Model_Product
$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 - Echo Attribute nella pagina del prodotto
- 2. Magento - get current product
- 3. Magento - Get personalizzati dettagli value option da Valore opzione ID
- 4. Tkinter: AttributeError: NoneType object has no attribute get
- 5. Get matrice da modello per ricercare altri
- 6. Get Index in jQuery modello
- 7. get convalide dal modello
- 8. backbone.js che accede agli attributi del modello all'interno del modello - this.attribute VS this.get ('attribute')?
- 9. Magento one page checkout- get TypeError: checkout undefined (in opcheckout.js)
- 10. Entity Framework 4.1 InverseProperty Attribute
- 11. Magento Store - Get URL di base in Static Block
- 12. XPATH remove attribute
- 13. C# Get sottostringa con il modello specifico da stringa
- 14. Usi il modello get/set (in Python)?
- 15. Backbone.js - Get matrice JSON in vista modello
- 16. Get reattiva var da un altro modello nella Meteor
- 17. Get enum da attributo enum
- 18. Django- Get Chiave esterna Modello
- 19. Obbligazione modello e richieste GET?
- 20. Il modello Magento non salverà i valori
- 21. Authorize Attribute Lifecycle
- 22. XSD Restriction on Attribute
- 23. GCC Bitwise Attribute
- 24. Attribute Routing e CreatedAtRoute
- 25. Magento Resource esclusione dei clienti modello
- 26. Modello e-mail Magento Se Istruzioni
- 27. Rails simple_form attribute required mark (*)
- 28. Identity Authorize Attribute Roles with Web API
- 29. remove attribute display: none; modo da l'articolo sarà visibile
- 30. Ottenere prodotti da un ordine in Magento
Grazie. Proverò a confermare il risultato. – vietean
Ho usato il tuo codice qui sopra per scoprire se la descrizione breve è 'Visibile sulla pagina Visualizza prodotto sul front-end': $ attributeShortDescription = Mage :: getModel ('eav/entity_attribute') -> loadByCode ('catalog_product', 'short_description '); $ attributeShortDescription-> getIsVisibleOnFront(); Versione –
utilizzando le costanti: $ _attr = Mage :: getModel ('eav/entity_attribute') -> loadByCode (Mage_Catalog_Model_Product :: ENTITY, $ attributeCode); –