本文整理汇总了PHP中Mage_Eav_Model_Entity_Setup::getEntityTypeId方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Eav_Model_Entity_Setup::getEntityTypeId方法的具体用法?PHP Mage_Eav_Model_Entity_Setup::getEntityTypeId怎么用?PHP Mage_Eav_Model_Entity_Setup::getEntityTypeId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Eav_Model_Entity_Setup
的用法示例。
在下文中一共展示了Mage_Eav_Model_Entity_Setup::getEntityTypeId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _prepareCollection
/**
* prepare collection for block to display
*
* @return Magestore_Customerattribute_Block_Adminhtml_Customerattribute_Grid
*/
protected function _prepareCollection()
{
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$entityTypeId = $setup->getEntityTypeId('customer');
$tbl_faq_item = Mage::getSingleton('core/resource')->getTableName('customerattribute/customerattribute');
$collection = Mage::getResourceModel('eav/entity_attribute_collection')->setEntityTypeFilter($entityTypeId);
$collection->getSelect()->join(array('table_attribute' => $tbl_faq_item), 'main_table.attribute_id=table_attribute.attribute_id');
$this->setCollection($collection);
return parent::_prepareCollection();
}
示例2: getAttributeLabel
public function getAttributeLabel($data)
{
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$entityTypeId = $setup->getEntityTypeId('customer');
$tbl_faq_item = Mage::getSingleton('core/resource')->getTableName('customerattribute/customerattribute');
$customerAttribute = Mage::getResourceModel('eav/entity_attribute_collection')->setEntityTypeFilter($entityTypeId);
$customerAttribute->getSelect()->join(array('table_attribute' => $tbl_faq_item), 'main_table.attribute_id=table_attribute.attribute_id');
$customerAttribute->addFieldToFilter('table_attribute.is_custom', 1);
$customerAttribute->addFieldToFilter('frontend_input', 'date');
foreach ($customerAttribute as $a) {
$data = $this->_filterDates($data, array($a->getAttributeCode(), 'valid_to'));
}
return $data;
}
示例3: _prepareColumns
protected function _prepareColumns()
{
$this->addColumn('real_order_id', array('header' => Mage::helper('sales')->__('Order #'), 'width' => '80px', 'type' => 'text', 'index' => 'increment_id'));
if (!Mage::app()->isSingleStoreMode()) {
$this->addColumn('store_id', array('header' => Mage::helper('sales')->__('Purchased From (Store)'), 'index' => 'store_id', 'type' => 'store', 'store_view' => true, 'display_deleted' => true));
}
$this->addColumn('created_at', array('header' => Mage::helper('sales')->__('Purchased On'), 'index' => 'created_at', 'type' => 'datetime', 'width' => '100px'));
$this->addColumn('billing_name', array('header' => Mage::helper('sales')->__('Bill to Name'), 'index' => 'billing_name'));
$this->addColumn('shipping_name', array('header' => Mage::helper('sales')->__('Ship to Name'), 'index' => 'shipping_name'));
// Add Column Customer Attribute to Order grid create by Hoatq
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$entityTypeId = $setup->getEntityTypeId('customer');
$tbl_faq_item = Mage::getSingleton('core/resource')->getTableName('customerattribute/customerattribute');
$models = Mage::getModel('customer/attribute')->getCollection();
$models->getSelect()->join(array('table_attribute' => $tbl_faq_item), 'main_table.attribute_id=table_attribute.attribute_id');
//->addFieldToFilter('main_table.attribute_id',$customerattributeId);
$models->addFieldToFilter('show_on_grid_order', 1);
$i = 0;
if ($i == 0) {
foreach ($models as $model) {
$index = 'customer_' . $model->getAttributeCode();
$frontend_input = $model->getFrontendInput();
if ($frontend_input != 'file' && $frontend_input != 'image') {
if ($frontend_input == 'boolean') {
$this->addColumn($index, array('header' => Mage::helper('sales')->__('Customer ' . str_replace('_', ' ', $model->getAttributeCode())), 'index' => $index, 'align' => 'center', 'type' => 'options', 'options' => array(0 => 'No', 1 => 'Yes')));
} elseif ($frontend_input == 'multiselect') {
$this->addColumn($index, array('header' => Mage::helper('sales')->__('Customer ' . str_replace('_', ' ', $model->getAttributeCode())), 'index' => $index, 'align' => 'center', 'type' => 'options', 'options' => Mage::helper('customerattribute')->getOptions($show['attribute_id']), 'renderer' => 'Magestore_Customerattribute_Block_Adminhtml_Sales_Order_Renderer_Multiselect', 'filter' => false));
} elseif ($frontend_input == 'select') {
$this->addColumn($index, array('header' => Mage::helper('sales')->__('Customer ' . str_replace('_', ' ', $model->getAttributeCode())), 'index' => $index, 'type' => 'options', 'options' => Mage::helper('customerattribute')->getOptions($model->getId())));
} elseif ($frontend_input == 'date') {
$this->addColumn($index, array('header' => Mage::helper('sales')->__('Customer ' . str_replace('_', ' ', $model->getAttributeCode())), 'index' => $index, 'type' => 'date', 'format' => Mage::helper('customerattribute')->getDateFormat1(), 'filter' => false));
} else {
$this->addColumn($index, array('header' => Mage::helper('sales')->__('Customer ' . str_replace('_', ' ', $model->getAttributeCode())), 'index' => $index));
}
}
}
$i++;
}
// -----------------------------------
$this->addColumn('base_grand_total', array('header' => Mage::helper('sales')->__('G.T. (Base)'), 'index' => 'base_grand_total', 'type' => 'currency', 'currency' => 'base_currency_code'));
$this->addColumn('grand_total', array('header' => Mage::helper('sales')->__('G.T. (Purchased)'), 'index' => 'grand_total', 'type' => 'currency', 'currency' => 'order_currency_code'));
$this->addColumn('status', array('header' => Mage::helper('sales')->__('Status'), 'index' => 'status', 'type' => 'options', 'width' => '70px', 'options' => Mage::getSingleton('sales/order_config')->getStatuses()));
if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
$this->addColumn('action', array('header' => Mage::helper('sales')->__('Action'), 'width' => '50px', 'type' => 'action', 'getter' => 'getId', 'actions' => array(array('caption' => Mage::helper('sales')->__('View'), 'url' => array('base' => '*/sales_order/view'), 'field' => 'order_id')), 'filter' => false, 'sortable' => false, 'index' => 'stores', 'is_system' => true));
}
$this->addRssList('rss/order/new', Mage::helper('sales')->__('New Order RSS'));
$this->addExportType('*/*/exportCsv', Mage::helper('sales')->__('CSV'));
$this->addExportType('*/*/exportExcel', Mage::helper('sales')->__('Excel XML'));
return $this;
}
示例4: _prepareColumns
protected function _prepareColumns()
{
$i = 0;
$this->addColumn('entity_id', array('header' => Mage::helper('customerattribute')->__('ID'), 'align' => 'right', 'width' => '50px', 'index' => 'entity_id'));
$this->addColumn('name', array('header' => Mage::helper('customerattribute')->__('Name'), 'align' => 'left', 'width' => '150px', 'index' => 'name'));
$this->addColumn('email', array('header' => Mage::helper('customerattribute')->__('Email'), 'align' => 'left', 'width' => '150px', 'index' => 'email'));
$groups = Mage::getResourceModel('customer/group_collection')->addFieldToFilter('customer_group_id', array('gt' => 0))->load()->toOptionHash();
$this->addColumn('group', array('header' => Mage::helper('customerattribute')->__('Group'), 'width' => '100', 'index' => 'group_id', 'type' => 'options', 'options' => $groups));
if ($i == 0) {
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$entityTypeId = $setup->getEntityTypeId('customer');
$tbl_faq_item = Mage::getSingleton('core/resource')->getTableName('customerattribute/customerattribute');
$shows = Mage::getModel('customer/attribute')->getCollection();
$shows->getSelect()->join(array('table_attribute' => $tbl_faq_item), 'main_table.attribute_id=table_attribute.attribute_id')->order('sort_order ASC');
//->addFieldToFilter('main_table.attribute_id',$customerattributeId);
$shows->addFieldToFilter('show_on_grid_customer', 1);
foreach ($shows as $show) {
if ($show['frontend_input'] == 'select') {
$this->addColumn($show['attribute_code'], array('header' => Mage::helper('customerattribute')->__($show['frontend_label']), 'align' => 'left', 'type' => 'options', 'options' => Mage::helper('customerattribute')->getOptions($show['attribute_id']), 'index' => $show['attribute_code']));
} else {
if ($show['frontend_input'] == 'multiselect') {
$this->addColumn($show['attribute_code'], array('header' => Mage::helper('customerattribute')->__($show['frontend_label']), 'align' => 'left', 'type' => 'options', 'options' => Mage::helper('customerattribute')->getOptions($show['attribute_id']), 'index' => $show['attribute_code'], 'renderer' => 'Magestore_Customerattribute_Block_Adminhtml_Managecustomer_Renderer_Multiselect', 'filter_condition_callback' => array($this, '_multiSelectFilter')));
} else {
if ($show['frontend_input'] == 'image') {
$this->addColumn($show['attribute_code'], array('header' => Mage::helper('customerattribute')->__($show['frontend_label']), 'align' => 'center', 'type' => 'image', 'width' => 60, 'index' => $show['attribute_code'], 'renderer' => 'Magestore_Customerattribute_Block_Adminhtml_Managecustomer_Renderer_Image', 'filter' => false));
} else {
if ($show['frontend_input'] == 'boolean') {
$this->addColumn($show['attribute_code'], array('header' => Mage::helper('customerattribute')->__($show['frontend_label']), 'align' => 'left', 'type' => 'options', 'options' => array(0 => 'No', 1 => 'Yes'), 'index' => $show['attribute_code']));
} else {
if ($show['frontend_input'] == 'file') {
$this->addColumn($show['attribute_code'], array('header' => Mage::helper('customerattribute')->__($show['frontend_label']), 'align' => 'left', 'type' => 'image', 'index' => $show['attribute_code'], 'renderer' => 'Magestore_Customerattribute_Block_Adminhtml_Managecustomer_Renderer_File', 'filter' => false));
} else {
if ($show['frontend_input'] == 'date') {
$this->addColumn($show['attribute_code'], array('header' => Mage::helper('customerattribute')->__($show['frontend_label']), 'align' => 'left', 'type' => 'datetime', 'gmtoffset' => true, 'index' => $show['attribute_code'], 'format' => Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM)));
} else {
$this->addColumn($show['attribute_code'], array('header' => Mage::helper('customerattribute')->__($show['frontend_label']), 'align' => 'left', 'type' => $show['frontend_input'], 'index' => $show['attribute_code']));
}
}
}
}
}
}
}
$i++;
}
$this->addColumn('action', array('header' => Mage::helper('customerattribute')->__('Action'), 'width' => '100px', 'type' => 'action', 'getter' => 'getId', 'actions' => array(array('caption' => Mage::helper('customerattribute')->__('Edit'), 'url' => array('base' => 'adminhtml/customer/edit'), 'field' => 'id')), 'filter' => false, 'sortable' => false, 'index' => 'stores', 'is_system' => true));
$this->addExportType('*/*/exportCsv', Mage::helper('customerattribute')->__('CSV'));
$this->addExportType('*/*/exportXml', Mage::helper('customerattribute')->__('XML'));
return parent::_prepareColumns();
}
示例5: getCustomtabInfo
public function getCustomtabInfo($tab)
{
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$entityTypeId = $setup->getEntityTypeId('customer');
//$storeId=$this->getCustomerAttribute()->getStoreId();
//$group=$this->getCustomerAttribute()->getGroupId();
$tbl_faq_item = Mage::getSingleton('core/resource')->getTableName('customerattribute/customerattribute');
$customerAttribute = Mage::getResourceModel('eav/entity_attribute_collection')->setEntityTypeFilter($entityTypeId);
$customerAttribute->getSelect()->join(array('table_attribute' => $tbl_faq_item), 'main_table.attribute_id=table_attribute.attribute_id');
$customerAttribute->addFieldToFilter('table_attribute.is_custom', 1);
$customerAttribute->addFieldToFilter('table_attribute.custom_tab', $tab);
//if($storeId!=0)
//$customerAttribute->addFieldToFilter('table_attribute.store_id',array('like'=>'%'.$storeId.'%'));
//$customerAttribute->addFieldToFilter('table_attribute.customer_group',array("like"=>'%'.$group.'%'));
return $customerAttribute;
}
示例6: editAction
/**
* view and edit item action
*/
public function editAction()
{
$attributeId = $this->getRequest()->getParam('id');
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$entityTypeId = $setup->getEntityTypeId('customer_address');
$tbl_faq_item = Mage::getSingleton('core/resource')->getTableName('customerattribute/customeraddressattribute');
$models = Mage::getResourceModel('eav/entity_attribute_collection')->setEntityTypeFilter($entityTypeId);
$models->getSelect()->join(array('table_attribute' => $tbl_faq_item), 'main_table.attribute_id=table_attribute.attribute_id');
$models->addFieldToFilter('main_table.attribute_id', $attributeId);
$model = $models->getFirstItem();
// register attribute object
Mage::register('customeraddressattribute_data', $model);
$this->loadLayout();
$this->_setActiveMenu('customer/customerattribute/customeraddressattribute');
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
$this->_addContent($this->getLayout()->createBlock('customerattribute/adminhtml_customeraddressattribute_edit'))->_addLeft($this->getLayout()->createBlock('customerattribute/adminhtml_customeraddressattribute_edit_tabs'));
$this->renderLayout();
}
示例7: array
Mage::app()->setCurrentStore(Mage::getModel('core/store')->load(Mage_Core_Model_App::ADMIN_STORE_ID));
$installer = $this;
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$installer->startSetup();
/**
* Adding a lookup table for Divido
*/
$conn = $installer->getConnection();
$lookup_table = $conn->newTable($installer->getTable('callback/lookup'));
$lookup_table->addColumn('lookup_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array('identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true), 'Id')->addColumn('salt', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array('nullable' => false), 'Salt')->addColumn('quote_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array('nullable' => false, 'unsigned' => true), 'Quote ID');
$lookup_table->addIndex($installer->getIdxName('callback/lookup', array('quote_id'), Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE), array('quote_id'), array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE));
$conn->createTable($lookup_table);
/**
* Adding Divido attributes to products
*/
$groupName = 'Divido';
$entityTypeId = $setup->getEntityTypeId('catalog_product');
$defaultAttrSetId = $setup->getDefaultAttributeSetId($entityTypeId);
// adding attribute group
$setup->addAttributeGroup($entityTypeId, $defaultAttrSetId, $groupName, 1000);
$groupId = $setup->getAttributeGroupId($entityTypeId, $defaultAttrSetId, $groupName);
// Add attributes
$planOptionAttrCode = 'divido_plan_option';
$setup->addAttribute($entityTypeId, $planOptionAttrCode, array('label' => 'Available on finance', 'type' => 'varchar', 'input' => 'select', 'backend' => 'eav/entity_attribute_backend_array', 'frontend' => '', 'source' => 'pay/source_option', 'default' => 'default_plans', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'visible' => true, 'required' => true, 'user_defined' => true, 'searchable' => true, 'filterable' => false, 'comparable' => false, 'visible_on_front' => true, 'unique' => false));
$planOptionAttrId = $setup->getAttributeId($entityTypeId, $planOptionAttrCode);
$setup->addAttributeToGroup($entityTypeId, $defaultAttrSetId, $groupId, $planOptionAttrId, null);
$planSelectionAttrCode = 'divido_plan_selection';
$setup->addAttribute($entityTypeId, $planSelectionAttrCode, array('label' => 'Selected plans', 'type' => 'varchar', 'input' => 'multiselect', 'backend' => 'eav/entity_attribute_backend_array', 'frontend' => '', 'source' => 'pay/source_defaultprodplans', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'visible' => true, 'required' => false, 'user_defined' => true, 'searchable' => true, 'filterable' => false, 'comparable' => false, 'visible_on_front' => true, 'unique' => false));
$planSelectionAttrId = $setup->getAttributeId($entityTypeId, $planSelectionAttrCode);
$setup->addAttributeToGroup($entityTypeId, $defaultAttrSetId, $groupId, $planSelectionAttrId, null);
$installer->endSetup();
示例8:
<?php
$installer = $this;
$installer->startSetup();
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$entityTypeId = $setup->getEntityTypeId('customer_address');
$attributeSetId = $setup->getDefaultAttributeSetId($entityTypeId);
$attributeGroupId = $setup->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
$setup->addAttributeToGroup($entityTypeId, $attributeSetId, $attributeGroupId, 'tax_invoice', '999');
$setup->endSetup();
$installer->endSetup();
示例9: saveAction
public function saveAction()
{
if ($data = $this->getRequest()->getPost()) {
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$entityTypeId = $setup->getEntityTypeId('customer');
$attributeSetId = $setup->getDefaultAttributeSetId($entityTypeId);
$attributeGroupId = $setup->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
$attributeObject = Mage::getModel('customer/attribute');
$attributeId = $this->getRequest()->getParam('id');
$helper = Mage::helper('customerattribute');
$attributeType = $attributeObject->load($attributeId)->getFrontendInput();
if ($attributeId != null) {
$data['frontend_input'] = $attributeType;
}
$data['validate_rules'] = $helper->getAttributeValidateRules1($data['frontend_input'], $data);
if ($data['is_custom'] == 1 || $attributeId == 0) {
if ($data['status'] == 1) {
if (in_array(1, $data['display_on_frontend'])) {
$data['used_in_forms'][] = 'customer_account_create';
}
if (in_array(2, $data['display_on_frontend'])) {
$data['used_in_forms'][] = 'customer_account_edit';
}
if ((in_array(3, $data['display_on_frontend']) || in_array(4, $data['display_on_frontend'])) && $attributeType != 'file' && $attributeType != 'image') {
$data['used_in_forms'][] = 'checkout_register';
}
if (in_array(1, $data['display_on_backend'])) {
$data['used_in_forms'][] = 'customer_Grid';
}
if (in_array(2, $data['display_on_backend'])) {
$data['used_in_forms'][] = 'order_grid';
}
if (in_array(3, $data['display_on_backend']) && $attributeType != 'file' && $attributeType != 'image') {
$data['used_in_forms'][] = 'adminhtml_checkout';
}
$data['used_in_forms'][] = 'tabCustomerattribute';
} else {
$data['used_in_forms'][] = array();
}
}
try {
$data1 = array('status' => $data['status'], 'show_on_create_account' => (int) in_array(1, $data['display_on_frontend']), 'show_on_account_edit' => (int) in_array(2, $data['display_on_frontend']), 'show_on_checkout_register_customer' => (int) in_array(3, $data['display_on_frontend']), 'show_on_checkout_register_guest' => (int) in_array(4, $data['display_on_frontend']), 'show_on_grid_customer' => (int) in_array(1, $data['display_on_backend']), 'show_on_grid_order' => (int) in_array(2, $data['display_on_backend']), 'show_on_admin_checkout' => (int) in_array(3, $data['display_on_backend']), 'customer_group' => implode(", ", $data['customer_group']), 'store_id' => implode(", ", $data['store_view']));
if ($attributeType == 'file' || $attributeType == 'image') {
$data1['show_on_checkout_register_customer'] = 0;
$data1['show_on_checkout_register_guest'] = 0;
$data1['show_on_admin_checkout'] = 0;
}
$model = Mage::getModel('customerattribute/customerattribute');
if ($attributeId) {
$models = Mage::getModel('customerattribute/customerattribute')->getCollection()->addFieldToFilter('attribute_id', $attributeId)->getFirstItem();
$data1['attribute_id'] = $attributeId;
$attributeObject->load($attributeId)->addData($data);
$attributeObject->setId($attributeId)->save();
$model->load($models->getId())->setData($data1);
$model->setId($models->getId())->save();
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('customerattribute')->__('The customer attribute has been saved.'));
} else {
$data['attribute_code'] = str_replace(' ', '', $data['attribute_code']);
$data['attribute_code'] = strtolower($data['attribute_code']);
$defaultValueField = $helper->getAttributeDefaultValueByInput($data['frontend_input']);
if ($defaultValueField) {
$scopeKeyPrefix = $this->getRequest()->getParam('website') ? 'scope_' : '';
$data[$scopeKeyPrefix . 'default_value'] = $helper->stripTags($this->getRequest()->getParam($scopeKeyPrefix . $defaultValueField));
}
$data['entity_type_id'] = $entityTypeId;
$data['attribute_group_id'] = $attributeGroupId;
$data['attribute_set_id'] = $attributeSetId;
$data['backend_type'] = $helper->getAttributeBackendTypeByInputType($data['frontend_input']);
$data['backend_model'] = $helper->getAttributeBackendModelByInputType($data['frontend_input']);
$data['source_model'] = $helper->getAttributeSourceModelByInputType($data['frontend_input']);
$data['is_system'] = 0;
$data['is_user_defined'] = 1;
if ($data['frontend_input'] == 'date') {
$data['input_filter'] = 'date';
}
$attributeObject->setData($data);
$attributeId = $attributeObject->save()->getId();
$data1['is_custom'] = 1;
$data1['attribute_id'] = $attributeId;
$model->setData($data1)->save();
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('customerattribute')->__('The customer customer attribute has been saved.'));
// Addcolumn to orderattribute table create by Hoatq
$table = new Mage_Core_Model_Resource_Setup();
$table->getConnection()->addColumn($table->getTable('orderattribute'), 'customer_' . $data['attribute_code'], 'varchar(255)');
}
} catch (Exception $e) {
if (!$attributeId) {
$attributeCode = $data['attribute_code'];
$attributeObject = $this->_initAttribute()->loadByCode($this->_getEntityType()->getId(), $attributeCode);
if ($attributeObject->getId()) {
$this->_getSession()->addError(Mage::helper('customerattribute')->__('Attribute with the same code already exists'));
}
} else {
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('customerattribute')->__('Unable to find item to save'));
}
}
if ($this->getRequest()->getParam('back', false)) {
$this->_redirect('*/*/edit', array('id' => $attributeId, '_current' => true));
return;
} else {
//.........这里部分代码省略.........
示例10:
<?php
/* @var $installer Mage_Customer_Model_Entity_Setup */
$installer = $this;
$installer->startSetup();
// Attributes
$attributeSetup = new Mage_Eav_Model_Entity_Setup('core_setup');
$entityTypeId = $attributeSetup->getEntityTypeId('customer');
$attributeSetId = $attributeSetup->getDefaultAttributeSetId($entityTypeId);
$attributeGroupId = $attributeSetup->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
$installer->addAttribute("customer", "is_b2b_approved", ["type" => "int", "label" => "Is B2B Approved?", "input" => "select", "visible" => false, "required" => false, "default" => 0, "source" => "eav/entity_attribute_source_boolean", "unique" => false, "note" => ""]);
$attribute = Mage::getSingleton("eav/config")->getAttribute("customer", "is_b2b_approved");
$attributeSetup->addAttributeToGroup($entityTypeId, $attributeSetId, $attributeGroupId, 'is_b2b_approved', '560');
$attribute->setData("used_in_forms", ["adminhtml_customer"])->setData("is_used_for_customer_segment", false)->setData("is_system", 0)->setData("is_user_defined", 1)->setData("is_visible", 0)->setData("sort_order", 560);
$attribute->save();
$installer->endSetup();
示例11: getAttributeHtml
/**
* Render attribute row and return HTML
*
* @param Mage_Eav_Model_Attribute $attribute
* @return string
*/
public function getAttributeHtml(Mage_Eav_Model_Attribute $attribute)
{
$showOnGuest = TRUE;
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$entityTypeId = $setup->getEntityTypeId('customer');
if ($attribute->getEntityTypeId() == $entityTypeId) {
$collection = Mage::getModel('customerattribute/customerattribute')->getCollection()->addFieldToFilter('attribute_id', $attribute->getAttributeId())->getFirstItem();
if ($collection->getShowOnCheckoutRegisterGuest() == 0) {
$showOnGuest = FALSE;
}
}
$type = $attribute->getFrontendInput();
$block = $this->getRenderer($type);
if ($block) {
$block->setAttributeObject($attribute)->setEntity($this->getEntity())->setFieldIdFormat($this->_fieldIdFormat)->setFieldNameFormat($this->_fieldNameFormat)->setShowOnGuest($showOnGuest);
return $block->toHtml();
}
return false;
}
示例12: array
// 'air_flow'=>'Air Flow (m3/h)',
// 'noise_level'=>'Noise Level',
// 'speed'=>'Speed',
// 'control'=>'Control',
// 'filter'=>'Filter',
// 'finish'=>'Finish',
// 'timer'=>'Timer',
// 'no_of_lamps'=>'No.Of Lamps',
// 'burner'=>'Burner (no)',
// 'triple_ring_burner'=>'Triple Ring Burner',
// 'flat_burner'=>'Flat Burner',
// 'warranty'=>'Warranty',
// 'type'=>'Type',
// 'no_of_ways'=>'No.Of Ways',
// 'no_of_pin'=>'No.Of Pin',
// 'no_of_modules'=>'No.Of Modules',
// 'ampere'=>'Ampere',
// 'trap_type'=>'Trap Type',
Mage::app('default');
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$installer = new Mage_Eav_Model_Entity_Setup('core_setup');
$entityTypeId = $installer->getEntityTypeId('catalog_product');
$attributeSetId = $installer->getDefaultAttributeSetId($entityTypeId);
$attributeGroupId = $installer->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
foreach ($attributes as $key => $value) {
try {
$installer->addAttribute('catalog_product', $key, array('group' => 'Specification', 'type' => 'varchar', 'backend' => 'eav/entity_attribute_backend_array', 'frontend' => '', 'class' => '', 'default' => '', 'label' => $value, 'input' => 'text', 'source' => '', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, 'is_visible' => 1, 'required' => 0, 'searchable' => 1, 'filterable' => 0, 'unique' => 0, 'comparable' => 0, 'visible_on_front' => 1, 'user_defined' => 1));
} catch (Exception $e) {
echo $e->getMessage();
}
}
示例13: array
<?php
/**
* Provides a custom SOAP client to enable communication with Streicher's
* Microsoft Dynamics Navision (NAV) ERP system via web services (SOAP/XMLRPC)
*
* @category Spe
* @package Spe_NavisionConnector
* @copyright Copyright (c) 2015 August Ash, Inc. (http://www.augustash.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
/** @var $installer Mage_Core_Model_Resource_Setup */
$installer = $this;
// Begin transaction
$installer->startSetup();
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$entityTypeId = $setup->getEntityTypeId('catalog_category');
$attributeSetId = $setup->getDefaultAttributeSetId($entityTypeId);
$attributeGroupId = $setup->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
$setup->addAttribute('catalog_category', 'thumbnail', array('type' => 'varchar', 'input' => 'image', 'backend' => 'catalog/category_attribute_backend_image', 'group' => 'General Information', 'label' => 'Thumbnail', 'visible' => 1, 'required' => 0, 'user_defined' => 1, 'frontend_input' => '', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'visible_on_front' => 1));
$setup->addAttributeToGroup($entityTypeId, $attributeSetId, $attributeGroupId, 'thumbnail', '5');
// End transaction
$installer->endSetup();
示例14: cleanAttributes
/**
* Remove fixture-generated attributes from database
*
* @param string $entityType
* @param array $attributes
* @throws EcomDev_PHPUnit_Model_Mysql4_Fixture_Exception
* @return EcomDev_PHPUnit_Model_Mysql4_Fixture_AbstractAttribute
*/
public function cleanAttributes($entityType, array $attributes)
{
$eavSetup = new Mage_Eav_Model_Entity_Setup('core_setup');
try {
if (empty($attributes)) {
throw new Exception('Attribute array cannot be empty');
} else {
$attributeCodes = array();
foreach ($attributes[$entityType] as $attribute) {
$attributeCodes[] = $attribute['attribute_code'];
}
}
//delete entry from eav/attribute and allow FK cascade to delete all related values
//TODO: check if the attribute != is_user_defined (ie system), then *only* delete the attribute option values, not attribute definition
$this->_getWriteAdapter()->delete($this->getTable('eav/attribute'), array('entity_type_id = ?' => $eavSetup->getEntityTypeId($entityType), 'attribute_code IN (?)' => $attributeCodes));
$this->_getWriteAdapter()->commit();
} catch (Exception $e) {
throw new EcomDev_PHPUnit_Model_Mysql4_Fixture_Exception(sprintf('Unable to clear records for a table "%s"', 'eav/attribute'), $e);
}
$this->resetAttributesAutoIncrement();
return $this;
}
示例15: testAction
public function testAction()
{
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$entity_type = Mage::getSingleton("eav/entity_type")->loadByCode("catalog_product");
$entity_type_id = $entity_type->getId();
$collection = Mage::getModel("eav/entity_attribute")->getCollection()->addFieldToFilter("entity_type_id", $entity_type_id)->addFieldToFilter("attribute_code", "giftwrap");
if (count($collection)) {
$collection->getFirstItem()->delete();
}
if (!count($collection)) {
$data = array('group' => 'General', 'type' => 'int', 'input' => 'select', 'label' => 'Wrappable', 'backend' => '', 'frontend' => '', 'source' => 'giftwrap/attribute_wrappable', 'visible' => 1, 'required' => 1, 'user_defined' => 1, 'is_searchable' => 1, 'is_filterable' => 0, 'is_comparable' => 1, 'is_visible_on_front' => 0, 'is_visible_in_advanced_search' => 1, 'used_for_sort_by' => 0, 'used_in_product_listing' => 1, 'used_for_price_rules' => 1, 'is_used_for_promo_rules' => 1, 'position' => 2, 'unique' => 0, 'is_configurable' => 1, 'default' => 0, 'is_global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE);
$setup->addAttribute('catalog_product', 'giftwrap', $data);
$entity_type_id = $setup->getEntityTypeId('catalog_product');
$data['entity_type_id'] = $entity_type_id;
$attribute = Mage::getModel("eav/entity_attribute")->setData($data)->setId($setup->getAttributeId('catalog_product', 'giftwrap'));
$attribute->save();
}
}