Introducing
Your new presentation assistant.
Refine, enhance, and tailor your content, source relevant images, and edit visuals quicker than ever before.
Trending searches
<config>
<global>
<customer>
<models>
<customer>
<class>Mage_Customer_Model</class>
<resourceModel>customer_entity</resourceModel>
</customer>
<customer_entity>
<class>Mage_Customer_Model_Entity</class>
<entities>
<entity>
<table>customer_entity</table>
</entity>
<address_entity>
<table>customer_address_entity</table>
</address_entity>
<value_prefix>
<table>customer_entity</table>
</value_prefix>
<customer_group>
<table>customer_group</table>
</customer_group>
</entities>
</customer_entity>
</models>
</customer>
</global>
</config>
Flat Catalog
public function getFlatIndexes();
Mage::getResourceModel('eav/entity_attribute')
->getFlatUpdateSelect($this->getAttribute(), $store);
Mage::getModel('catalog/product')->getCollection()->toOptionArray();
Mage_Eav_Model_Entity_Attribute_Source_Boolean
Mage_Eav_Model_Entity_Attribute_Source_Store
Mage_Eav_Model_Entity_Attribute_Source_Table
Mage_Eav_Model_Entity_Attribute_Source_Config
Mage_Customer_Model_Customer_Attribute_Source_Group
usw...
<?php
class Mm09_SampleModule_Model_Entity_Attribute_Source_Xignite
extends Mage_Eav_Model_Entity_Attribute_Source_Abstract
{
public function getAllOptions()
{
if (! $this->_options)
{
$this->_options = array(array(
'value' => '',
'label' => Mage::helper('SampleModule')->__('--- Please Choose ---')
));
$client = new SoapClient('http://www.xignite.com/xGlobalQuotes.asmx?WSDL');
$result = $client->GetGlobalDelayedQuotes(array('Identifiers' => 'BMW.DE,MTV.L,RSL.L', 'IdentifierType' => 'Symbol'));
foreach ($result->GetGlobalDelayedQuotesResult->GlobalQuote as $record)
{
$this->_options[] = array(
'value' => $record->Security->Symbol,
'label' => sprintf('%s (%s)', $record->Security->Name, $record->Security->Market)
);
}
}
return $this->_options;
}
}
afterLoad();
beforeSave();
afterSave();
beforeDelete();
afterDelete();
validate();
public function getValue(Varien_Object $object)
{
$data = '';
if ($value = parent::getValue($object))
{
$data = Mage::getSingleton('core/locale')->date($value, Zend_Date::ISO_8601, null, false)
->toString('YYYY-MM-dd HH:ii:ss');
}
return $data;
}
public function getInputRendererClass();
entity_type_id | entity_type_code | entity_model | entity_table | attribute_model | ...
FK eav_entity.entity_type_id
unique ID
Default ist eav/entity_attribute
Default eav/entity_attribute
Default eav/entity_attribute_backend_default
Default eav/entity_attribute_source_config
unique ID
Default eav/entity_attribute_frontend_default
customer/entity
mm09.2 in ffm
02.11.2009
von Vinai Kopp
Formatieren vor der Ausgabe
für komplexe Backend Interfaces
Block Klasse, Varien_Data_Form_Element_Abstract
public function getElementHtml();
<?php
abstract class Mm09_SampleModule_Model_Entity_Attribute_Frontend_Sample
extends Mage_Eav_Model_Entity_Attribute_Frontend_Abstract
{
public function getValue($object)
{
$value = parent::getValue($object)
if (! isset($value))
{
$value = Mage::getStoreConfig('general/sample_module/default_value');
}
return $value;
}
}
(ein unsinniges Beispiel...!)
Freier Programmierer
vinai@netzarbeiter.de
+49 173 - 31 33 444
Deutsches offizielles Magento Forum: http://www.magentocommerce.com/boards/viewforum/25/
IRC irc.freenode.net Channel #magento-de (deutsch) oder #magento (english)
Dokumentation?
t3n Magazin: regelmäßig Magento Artikel
Liste mit Magento-Development Blogs http://blog.velite.de/essential-magento-developer-blogs/
... Zeitlos und immer Richtig: use the Source...!
Bücher:
Online-Shops mit Magento (Roman Zenner)
Magento - Das Handbuch für Entwickler (Visions new Media Entwickler)
Mage_Core_Model_Abstract
return array(
array(
'value' => '',
'label' => Mage::helper('core')->__('--- Please Choose ---'),
),
array(
'value' => 'wert1',
'label' => 'Option Eins'
),
array(
'value' => 'wert2',
'label' => 'Option Zwei'
)
);
<?php
$this->startSetup();
$this->addAttribute('catalog_product', 'source_sample', array(
'label' => 'xIgnite SOAP API',
'type' => 'varchar',
'input' => 'select',
'source' => 'SampleModule/entity_attribute_source_xignite',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
'visible' => 1,
'visible_on_front' => 0,
'required' => 0,
'user_defined' => 1,
'default' => ''
));
$this->endSetup();
<?php
abstract class Mm09_SampleModule_Model_Entity_Attribute_Sample
extends Mage_Catalog_Model_Resource_Eav_Attribute
{
public function getDefaultValue()
{
$value = Mage::getStoreConfig('general/sample_module/default_value');
return $value;
}
}
<global>
<modul>
<fields>
<red><label>Rotwein</label> </red>
<white><label>Weißwein</label></white>
<champagne><label>Sekt</label></champagne>
<desert><label>Dessertwein</label></desert>
</fields>
</modul>
</global>
if ($config = Mage::getConfig()->getNode('global/modul/fields')->asArray())
{
if (is_array($config)) foreach ($config as $value => $data)
{
$this->_options[] = array(
'value' => $value,
'label' => $data['label'],
);
}
}
function _construct()
{
$this->_init('customer/customer');
}
protected function _init($resourceModel)
{
$this->_setResourceModel($resourceModel);
}
mapped to Mage_Customer_Model_Entity_Customer
$indexName = $this->getAttribute()->getAttributeCode();
array(
$indexName => 'attribute_column_name',
...
)
getBackend()
getSource()
getFrontend()
getEntity()
Bug in Mage_Eav_Model_Entity_Attribute_Source_Abstract::getOptionText()
Behoben in Magento 1.4
public function
... Product und Category Attribute
für Product und Category select/multiselect Attribute...
$columnName = $this->getAttribute()->getAttributeCode();
array(
$columnName = array(
'type' => 'int',
'unsigned' => false,
'is_null' => true,
'default' => null,
'extra' => null
)
);
public function getFlatColumns();
für non-Select/Multiselect Attribute
Varien_Db_Select das den Wert des Attributes zurückliefert.
Default Source Models
public function getFlatUpdateSelect($store);
Mage_Eav_Model_Entity_Abstract
public function validate($object)
{
if (parent::validate($object))
{
$attrCode = $this->getAttribute()->getAttributeCode();
$data = $object->getData($attrCode);
if ($data)
{
if (! is_numeric($data))
{
Mage::throwException(Mage::helper('SampleModule')->__('The amount must be a numeric value'));
}
if ($data < 0)
{
Mage::throwException(Mage::helper('SampleModule')->__('The amount must greater then zero'));
}
}
}
return true;
}
Mage_Eav_Model_Entity_Attribute_Backend_Array
Mage_Eav_Model_Entity_Attribute_Backend_Datetime
Mage_Eav_Model_Entity_Attribute_Backend_Increment
Mage_Eav_Model_Entity_Attribute_Backend_Store
Mage_Customer_Model_Customer_Attribute_Backend_Password
Mage_Catalog_Model_Product_Attribute_Backend_Media
... und viele mehr
public function getReadConnection();
public function loadAllAttributes($object=null);
public function getWriteConnection();
public function getAttribute($attribute);
public function beginTransaction();
public function saveAttribute(Varien_Object $object, $attributeCode);
public function commit();
public function rollBack();
... wie der Name schon sagt
Cleanup
... Files löschen
... Alternative zu model_delete_after Events
Integrity Checks - darf gelöscht werden?
Eigene Trigger anstoßen
... Caching
... externe Systeme
... Alternative zum afterSave() im Model
Default Werte setzen
Werte aktualisieren
Daten zum Speichern formatieren
Nachladen von Werten aus
weiteren Tabellen / Dateien
public function getEntityIdField();
public function
Feld zum Joinen der Value Tabelle mit der Entity Tabelle
Default: entity_id aus Mage_Eav_Model_Entity::DEFAULT_ENTITY_ID_FIELD
public function getTable();
Für backend_type = 'static' backend_table der Entity
Name der Tabelle mit für den Wert des Attributs
EAV Attribute - backend_table der Entity . '_' . Data-Type