/** * * @return type */ public function getAttributes() { $attributes = parent::getAttributes(); if (Mage::app()->getRequest()->getRouteName() == 'adminhtml') { if (Mage::app()->getRequest()->isPost()) { $data = Mage::app()->getRequest()->getParam('tabCustomerattribute'); $customerTypeValue = $data['select_customer_type']; $customerTypeText = Mage::helper('idpas400')->getAttributeOptionText($customerTypeValue); $attributes = Mage::helper('idpas400')->filterAttributesArray($attributes, $customerTypeText); } // Filter the attributes if this is a post on the front controller } elseif (Mage::app()->getRequest()->isPost()) { $customerTypeValue = Mage::app()->getRequest()->getParam('select_customer_type'); $customerTypeText = Mage::helper('idpas400')->getAttributeOptionText($customerTypeValue); $attributes = Mage::helper('idpas400')->filterAttributesArray($attributes, $customerTypeText); // if the user is logged in, then we're looking at their account page // } elseif (Mage::helper('customer')->isLoggedIn()) { // $_attr = array(); // foreach ($attributes as $code => $attribute) { // if ($code == 'select_customer_type') { // $attribute->setData('is_visible',0); // $attribute->setData('is_required',0); // continue; // } // $_attr[$code] = $attribute; // } // $attributes = $_attr; } return $attributes; }
public function getAttributes() { $attributes = parent::getAttributes(); $realAction = Mage::app()->getRequest()->getBeforeForwardInfo(); $formCode = $this->getFormCode(); if (strcmp($formCode, 'adminhtml_customer_address') == 0) { return $attributes; } if (isset($realAction['action_name'])) { $actionName = $realAction['action_name']; } else { $actionName = Mage::app()->getRequest()->getActionName(); } //action_name index, edit, new $pageIsCustomerEdit = strcmp(Mage::app()->getRequest()->getControllerName(), 'customer') == 0 && strcmp($actionName, 'edit') == 0; $collection = Mage::getModel('customer/attribute')->getCollection(); $alias = Mage::helper('amcustomerattr')->getProperAlias($collection->getSelect()->getPart('from'), 'eav_attribute'); $collection->addFieldToFilter($alias . 'is_user_defined', 1); $collection->addFieldToFilter($alias . 'entity_type_id', Mage::getModel('eav/entity')->setType('customer')->getTypeId()); $alias = Mage::helper('amcustomerattr')->getProperAlias($collection->getSelect()->getPart('from'), 'customer_eav_attribute'); $collection->getSelect()->order($alias . 'sorting_order'); $temp = array(); $entityType = Mage::getSingleton('eav/config')->getEntityType('customer'); foreach ($attributes as $attribute) { $temp[] = $attribute->getAttributeCode(); } //$attribute->getOnRgistration() foreach ($collection as $attribute) { $attribute = Mage::getModel('customer/attribute')->loadByCode($entityType, $attribute->getName()); if ('selectgroup' == $attribute->getTypeInternal()) { // do not need to show `Customer Group Selector` attribute in the Backend continue; } // should not add attributes on the order create page in the backend if ('sales_order_create' != Mage::app()->getRequest()->getControllerName()) { if ('customer_activated' != $attribute->getAttributeCode() && 'unlock_customer' != $attribute->getAttributeCode()) { // filter attributes by store on the edit customer page in the backend if ($pageIsCustomerEdit) { $applicableStoreIds = explode(',', $attribute->getStoreIds()); // 0 means allowed on all store views if (!in_array(0, $applicableStoreIds)) { if (!in_array(Mage::registry('current_customer')->getStoreId(), $applicableStoreIds) && 0 != Mage::registry('current_customer')->getStoreId()) { continue; } } } if (!in_array($attribute->getAttributeCode(), $temp)) { $attributes[$attribute->getAttributeCode()] = $attribute; } } } } $this->_attributes = $attributes; return $attributes; }
public function getAttributes() { $attributes = parent::getAttributes(); // 1 entity type is customer attributes. if (1 != $this->getEntity()->getEntityTypeId()) { return $attributes; } $collection = Mage::getModel('customer/attribute')->getCollection(); $alias = Mage::helper('amcustomerattr')->getProperAlias($collection->getSelect()->getPart('from'), 'eav_attribute'); $collection->addFieldToFilter($alias . 'is_user_defined', 1); $collection->addFieldToFilter($alias . 'entity_type_id', Mage::getModel('eav/entity')->setType('customer')->getTypeId()); $alias = Mage::helper('amcustomerattr')->getProperAlias($collection->getSelect()->getPart('from'), 'customer_eav_attribute'); $collection->getSelect()->order($alias . 'sorting_order'); $temp = array(); $entityType = Mage::getSingleton('eav/config')->getEntityType('customer'); foreach ($attributes as $attribute) { $temp[] = $attribute->getAttributeCode(); } $attribute = Mage::getModel('customer/attribute')->loadByCode($entityType, $attribute->getName()); foreach ($collection as $attribute) { $attribute = Mage::getModel('customer/attribute')->loadByCode($entityType, $attribute->getName()); if ('selectgroup' == $attribute->getTypeInternal()) { // do not need to show `Customer Group Selector` attribute in the Backend continue; } // should not add attributes on the order create page in the backend if ('sales_order_create' != Mage::app()->getRequest()->getControllerName()) { if ('customer_activated' != $attribute->getAttributeCode() && 'unlock_customer' != $attribute->getAttributeCode()) { // filter attributes by store on the edit customer page in the backend if ('customer' == Mage::app()->getRequest()->getControllerName() && 'edit' == Mage::app()->getRequest()->getActionName()) { $applicableStoreIds = explode(',', $attribute->getStoreIds()); // 0 means allowed on all store views if (!in_array(0, $applicableStoreIds)) { if (!in_array(Mage::registry('current_customer')->getStoreId(), $applicableStoreIds) && 0 != Mage::registry('current_customer')->getStoreId()) { continue; } } } if (!in_array($attribute->getAttributeCode(), $temp)) { $attributes[] = $attribute; } } } } return $attributes; }
public function getAttributes() { $attributes = parent::getAttributes(); // 1 entity type is customer attributes. if (1 != $this->getEntity()->getEntityTypeId()) { return $attributes; } $collection = Mage::getModel('customer/attribute')->getCollection(); $collection->addFieldToFilter('is_user_defined', 1); $collection->addFieldToFilter('entity_type_id', Mage::getModel('eav/entity')->setType('customer')->getTypeId()); foreach ($collection as $attribute) { // should not add attributes on the order create page in the backend if ('sales_order_create' != Mage::app()->getRequest()->getControllerName()) { if ('customer_activated' != $attribute->getAttributeCode() && 'unlock_customer' != $attribute->getAttributeCode()) { $attributes[] = $attribute; } } } return $attributes; }
public function testGetAttributes() { $attributes = $this->_model->getAttributes(); $this->assertInternalType('array', $attributes); $this->assertNotEmpty($attributes); }
/** * Initialize attribute set * * @param Mage_Customer_Model_Form $customerFor * @return Mage_Eav_Model_Entity_Attribute[] */ protected function _initCustomerAttributes(Mage_Customer_Model_Form $customerForm) { $attributes = $customerForm->getAttributes(); foreach ($attributes as $attribute) { /* @var $attribute Mage_Eav_Model_Entity_Attribute */ $attributeLabel = Mage::helper('Mage_Customer_Helper_Data')->__($attribute->getFrontend()->getLabel()); $attribute->setFrontendLabel($attributeLabel); $attribute->unsIsVisible(); } return $attributes; }