本文整理汇总了PHP中Mage_Eav_Model_Entity_Attribute::loadByCode方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Eav_Model_Entity_Attribute::loadByCode方法的具体用法?PHP Mage_Eav_Model_Entity_Attribute::loadByCode怎么用?PHP Mage_Eav_Model_Entity_Attribute::loadByCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Eav_Model_Entity_Attribute
的用法示例。
在下文中一共展示了Mage_Eav_Model_Entity_Attribute::loadByCode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadByCode
public function loadByCode($code)
{
if ($code != "") {
parent::loadByCode(1, $code);
} else {
$this->setEntityTypeId(Mage::getModel('eav/entity')->setType("customer")->getTypeId());
}
return $this;
}
示例2: array
<?php
$installer = $this;
/* @var $installer Mage_Sales_Model_Mysql4_Setup */
$installer->startSetup();
$resource = Mage::getResourceModel('sales/order_collection');
if (!method_exists($resource, 'getEntity')) {
$table = $this->getTable('sales_flat_order');
$query = 'ALTER TABLE `' . $table . '` ADD COLUMN `onestepcheckout_customercomment` TEXT CHARACTER SET utf8 DEFAULT NULL';
$connection = Mage::getSingleton('core/resource')->getConnection('core_write');
$connection->query($query);
} else {
// Get ID of the entity model 'sales/order'.
$sql = 'SELECT entity_type_id FROM ' . $this->getTable('eav_entity_type') . ' WHERE entity_type_code="order"';
$row = Mage::getSingleton('core/resource')->getConnection('core_read')->fetchRow($sql);
// Create EAV-attribute for the order comment.
$c = array('entity_type_id' => $row['entity_type_id'], 'attribute_code' => 'onestepcheckout_customercomment', 'backend_type' => 'text', 'frontend_input' => 'textarea', 'is_global' => '1', 'is_visible' => '1', 'is_required' => '0', 'is_user_defined' => '0', 'frontend_label' => 'Customer Comment');
$attribute = new Mage_Eav_Model_Entity_Attribute();
$attribute->loadByCode($c['entity_type_id'], $c['attribute_code'])->setStoreId(0)->addData($c);
$attribute->save();
}
$installer->endSetup();
示例3: array
<?php
$installer = $this;
$installer->startSetup();
$resource = Mage::getResourceModel('sales/order_collection');
if (!method_exists($resource, 'getEntity')) {
$table = $this->getTable('sales_flat_order');
$query = 'ALTER TABLE `' . $table . '` ADD COLUMN `onestepcheckout_customerfeedback` TEXT CHARACTER SET utf8 DEFAULT NULL';
$connection = Mage::getSingleton('core/resource')->getConnection('core_write');
$connection->query($query);
} else {
$attribute = array('entity_type_id' => $installer->getEntityTypeId('order'), 'attribute_code' => 'onestepcheckout_customerfeedback', 'backend_type' => 'text', 'frontend_input' => 'textarea', 'is_global' => '1', 'is_visible' => '1', 'is_required' => '0', 'is_user_defined' => '0');
$newAttribute = new Mage_Eav_Model_Entity_Attribute();
$newAttribute->loadByCode($attribute['entity_type_id'], $attribute['attribute_code'])->setStoreId(0)->addData($attribute)->save();
}
$installer->endSetup();