Exemple #1
0
 /**
  * @param array $attribute1SetInfo
  * @param array $attribute2SetInfo
  * @param float $expected
  * @dataProvider compareAttributesDataProvider
  */
 public function testCompareAttributes($attribute1Sort, $attribute2Sort, $expected)
 {
     $attribute1 = $this->getMock('Mage_Eav_Model_Entity_Attribute', null, array(), '', false);
     $attribute1->setAttributeSetInfo(array(0 => $attribute1Sort));
     $attribute2 = $this->getMock('Mage_Eav_Model_Entity_Attribute', null, array(), '', false);
     $attribute2->setAttributeSetInfo(array(0 => $attribute2Sort));
     $this->assertEquals($expected, $this->_model->attributesCompare($attribute1, $attribute2));
 }
 /**
  * Retrieve select object for loading base entity row
  *
  * @param   Varien_Object $object
  * @param   mixed $rowId
  * @return  Zend_Db_Select
  */
 protected function _getLoadRowSelect($object, $rowId)
 {
     $select = parent::_getLoadRowSelect($object, $rowId);
     if ($object->getSharedStoreIds()) {
         $select->where('store_id IN (?)', $object->getSharedStoreIds());
     }
     return $select;
 }
 protected function _collectSaveData($newObject)
 {
     // when deleting store specific values, value ids should be in place
     if ($newObject->getStoreId()) {
         foreach ($this->getAttributesByCode() as $code => $attribute) {
             if ($attribute->getIsGlobal() == Mana_Core_Model_Attribute_Scope::_STORE && is_null($newObject->getData($code))) {
                 $attribute->getBackend()->setValueId($this->getStoreValueId($newObject, $attribute));
             }
         }
     }
     return parent::_collectSaveData($newObject);
 }
Exemple #4
0
 /**
  * Initialize attribute value for object
  *
  * @param   Varien_Object $object
  * @param   array $valueRow
  * @return  Mage_Eav_Model_Entity_Abstract
  */
 protected function _setAttribteValue($object, $valueRow)
 {
     parent::_setAttribteValue($object, $valueRow);
     if ($attribute = $this->getAttribute($valueRow['attribute_id'])) {
         $attributeCode = $attribute->getAttributeCode();
         if (isset($valueRow['store_value'])) {
             $object->setAttributeDefaultValue($attributeCode, $valueRow['value']);
             $object->setData($attributeCode, $valueRow['store_value']);
             $attribute->getBackend()->setValueId($valueRow['store_value_id']);
         }
     }
     return $this;
 }
 /**
  * Reset firstly loaded attributes
  *
  * @param Varien_Object $object
  * @param integer $entityId
  * @param array|null $attributes
  * @return Mage_Catalog_Model_Resource_Abstract
  */
 public function load($object, $entityId, $attributes = array())
 {
     $this->_attributes = array();
     return parent::load($object, $entityId, $attributes);
 }
 /**
  * Emulate customer resource model for easy access
  */
 protected function _construct()
 {
     $this->setType('customer');
     $this->setConnection('customer_read', 'customer_write');
     return parent::_construct();
 }
 /**
  * Enter description here...
  *
  * @return Mage_Eav_Model_Entity_Attribute_Abstract
  */
 public function getAttribute($attr)
 {
     return $this->_entity->getAttribute($attr);
 }
Exemple #8
0
 /**
  * Get attribute alias as "entity_type/attribute_code"
  *
  * @param Mage_Eav_Model_Entity_Abstract $entity exclude this entity
  * @return string
  */
 public function getAlias($entity = null)
 {
     $alias = '';
     if ($entity === null || $entity->getType() !== $this->getEntity()->getType()) {
         $alias .= $this->getEntity()->getType() . '/';
     }
     $alias .= $this->getAttributeCode();
     return $alias;
 }
 /**
  * Retrieve shipping carriers for specified order
  *
  * @param Mage_Eav_Model_Entity_Abstract $object
  * @return array
  */
 protected function _getCarriers($object)
 {
     $carriers = array();
     $carrierInstances = Mage::getSingleton('shipping/config')->getAllCarriers($object->getStoreId());
     $carriers['custom'] = Mage::helper('sales')->__('Custom Value');
     foreach ($carrierInstances as $code => $carrier) {
         if ($carrier->isTrackingAvailable()) {
             $carriers[$code] = $carrier->getConfigData('title');
         }
     }
     return $carriers;
 }
Exemple #10
0
 /**
  * Custom setter of increment ID if its needed
  *
  * @param Varien_Object $object
  * @return Mage_Customer_Model_Resource_Customer
  */
 public function setNewIncrementId(Varien_Object $object)
 {
     if (Mage::getStoreConfig(Mage_Customer_Model_Customer::XML_PATH_GENERATE_HUMAN_FRIENDLY_ID)) {
         parent::setNewIncrementId($object);
     }
     return $this;
 }
 /**
  * Added a fit size for items in large quantities.
  * Means you can join items like two or more glasses, pots and vases.
  * The calc is applied only for height side.
  * Required attribute fit_size. Example:
  *
  *         code: fit_size
  *         type: varchar
  *
  * After you can set a fit size for all products and improve your sells
  *
  * @param Mage_Eav_Model_Entity_Abstract $item Order Item
  *
  * @return number
  */
 protected function _getFitHeight($item)
 {
     $product = $item->getProduct();
     $height = $product->getData('volume_altura');
     $height = $height > 0 ? $height : (int) $this->getConfigData('altura_padrao');
     $fitSize = (double) $product->getData('fit_size');
     if ($item->getQty() > 1 && is_numeric($fitSize) && $fitSize > 0) {
         $totalSize = $height + $fitSize * ($item->getQty() - 1);
         $height = $totalSize / $item->getQty();
     }
     return $height;
 }
Exemple #12
0
 /**
  * Retrieve select object for loading base entity row
  *
  * @param   Varien_Object $object
  * @param   mixed $rowId
  * @return  Zend_Db_Select
  */
 protected function _getLoadRowSelect($object, $rowId)
 {
     $select = parent::_getLoadRowSelect($object, $rowId);
     if ($object->getWebsiteId() && $object->getSharingConfig()->isWebsiteScope()) {
         $select->where('website_id=?', (int) $object->getWebsiteId());
     }
     return $select;
 }
Exemple #13
0
 /**
  * Save customer addresses and set default addresses in attributes backend
  *
  * @param   Varien_Object $customer
  * @return  Mage_Eav_Model_Entity_Abstract
  */
 protected function _afterSave(Varien_Object $customer)
 {
     $this->_saveAddresses($customer);
     return parent::_afterSave($customer);
 }
 /**
  * @param Varien_Object $object
  * @return $this
  */
 protected function _beforeSave(Varien_Object $object)
 {
     parent::_beforeSave($object);
     $this->_changeTime($object);
     return $this;
 }
Exemple #15
0
 /**
  * Check customer address before saving
  *
  * @param Varien_Object $address
  * @return Mage_Customer_Model_Resource_Address
  */
 protected function _beforeSave(Varien_Object $address)
 {
     parent::_beforeSave($address);
     $this->_validate($address);
     return $this;
 }
 /**
  * Unserialize additional information after saving the object
  *
  * @param Varien_Object $payment
  */
 protected function _afterSave(Varien_Object $payment)
 {
     $this->unserializeFields($payment);
     return parent::_afterSave($payment);
 }