예제 #1
0
 /**
  * Check is attribute allowed
  *
  * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
  * @param array $attributes
  * @return boolean
  */
 protected function _isAllowedAttribute($attribute, array $filter = null)
 {
     if (!is_null($filter) && !(in_array($attribute->getAttributeCode(), $filter) || in_array($attribute->getAttributeId(), $filter))) {
         return false;
     }
     return !in_array($attribute->getFrontendInput(), $this->_ignoredAttributeTypes) && !in_array($attribute->getAttributeCode(), $this->_ignoredAttributeCodes);
 }
예제 #2
0
 protected function _isAttributeIndexable(Mage_Eav_Model_Entity_Attribute_Abstract $attribute)
 {
     if ($attribute->getFrontendInput() != 'price') {
         return false;
     }
     if ($attribute->getAttributeCode() == 'tier_price') {
         return false;
     }
     if ($attribute->getAttributeCode() == 'minimal_price') {
         return false;
     }
     return true;
 }
예제 #3
0
파일: Grid.php 프로젝트: ppkowalski/M2E
 public function callbackFilterPartsCompatibilityAttribute(Varien_Data_Collection_Db $collection, $column)
 {
     $value = $column->getFilter()->getValue();
     if (is_null($value)) {
         return;
     }
     if (!$this->partsCompatibilityAttribute) {
         return;
     }
     if ($value == 1) {
         $attributeCode = $this->partsCompatibilityAttribute->getAttributeCode();
         $collection->addFieldToFilter($attributeCode, array('notnull' => true));
         $collection->addFieldToFilter($attributeCode, array('neq' => ''));
         $collection->addFieldToFilter('is_parts_compatibility_attribute_in_product_attribute_set', array('notnull' => true));
     } else {
         $attributeId = $this->partsCompatibilityAttribute->getId();
         $storeId = $this->getListing()->getStoreId();
         $joinCondition = 'eaa.entity_id = e.entity_id and eaa.attribute_id = ' . $attributeId;
         if (!$this->partsCompatibilityAttribute->isScopeGlobal()) {
             $joinCondition .= ' and eaa.store_id = ' . $storeId;
         }
         $collection->getSelect()->joinLeft(array('eaa' => Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_text')), $joinCondition, array('value'));
         $collection->getSelect()->orWhere('eaa.value IS NULL');
         $collection->getSelect()->orWhere('eaa.value = \'\'');
         $collection->getSelect()->orWhere('eea.entity_attribute_id IS NULL');
     }
 }
예제 #4
0
 private function prepareExistingMotorsData()
 {
     $motorsHelper = Mage::helper('M2ePro/Component_Ebay_Motors');
     $products = $this->getCollection()->getItems();
     $productsMotorsData = array();
     $items = array();
     $filters = array();
     $groups = array();
     foreach ($products as $product) {
         if (!$product->getData('is_motors_attribute_in_product_attribute_set')) {
             continue;
         }
         $productId = $product->getData('listing_product_id');
         $attributeCode = $this->motorsAttribute->getAttributeCode();
         $attributeValue = $product->getData($attributeCode);
         $productsMotorsData[$productId] = $motorsHelper->parseAttributeValue($attributeValue);
         $items = array_merge($items, array_keys($productsMotorsData[$productId]['items']));
         $filters = array_merge($filters, $productsMotorsData[$productId]['filters']);
         $groups = array_merge($groups, $productsMotorsData[$productId]['groups']);
     }
     //-------------------------------
     $typeIdentifier = $motorsHelper->getIdentifierKey($this->getMotorsType());
     $select = Mage::getResourceModel('core/config')->getReadConnection()->select()->from($motorsHelper->getDictionaryTable($this->getMotorsType()), array($typeIdentifier))->where('`' . $typeIdentifier . '` IN (?)', $items);
     $existedItems = $select->query()->fetchAll(PDO::FETCH_COLUMN);
     //-------------------------------
     //-------------------------------
     $filtersTable = Mage::getSingleton('core/resource')->getTableName('m2epro_ebay_motor_filter');
     $select = Mage::getResourceModel('core/config')->getReadConnection()->select()->from($filtersTable, array('id'))->where('`id` IN (?)', $filters);
     $existedFilters = $select->query()->fetchAll(PDO::FETCH_COLUMN);
     //-------------------------------
     //-------------------------------
     $groupsTable = Mage::getSingleton('core/resource')->getTableName('m2epro_ebay_motor_group');
     $select = Mage::getResourceModel('core/config')->getReadConnection()->select()->from($groupsTable, array('id'))->where('`id` IN (?)', $groups);
     $existedGroups = $select->query()->fetchAll(PDO::FETCH_COLUMN);
     //-------------------------------
     foreach ($productsMotorsData as $productId => $productMotorsData) {
         foreach ($productMotorsData['items'] as $item => $itemData) {
             if (!in_array($item, $existedItems)) {
                 unset($productsMotorsData[$productId]['items'][$item]);
             }
         }
         foreach ($productMotorsData['filters'] as $key => $filterId) {
             if (!in_array($filterId, $existedFilters)) {
                 unset($productsMotorsData[$productId]['filters'][$key]);
             }
         }
         foreach ($productMotorsData['groups'] as $key => $groupId) {
             if (!in_array($groupId, $existedGroups)) {
                 unset($productsMotorsData[$productId]['groups'][$key]);
             }
         }
     }
     $this->productsMotorsData = $productsMotorsData;
     return $this;
 }
 /**
  * Retrieve Select for update Flat data
  *
  * @param   Mage_Eav_Model_Entity_Attribute_Abstract $attribute
  * @param   int $store
  * @param   bool $hasValueField flag which require option value
  * @return  Varien_Db_Select
  */
 public function getFlatUpdateSelect(Mage_Eav_Model_Entity_Attribute_Abstract $attribute, $store, $hasValueField = true)
 {
     $attributeTable = $attribute->getBackend()->getTable();
     $attributeCode = $attribute->getAttributeCode();
     $valueExpr = new Zend_Db_Expr("IFNULL(t2.value, t1.value)");
     $select = $this->_getReadAdapter()->select()->joinLeft(array('t1' => $attributeTable), "`e`.`entity_id`=`t1`.`entity_id` AND `e`.`child_id`=`t1`.`entity_id`", array())->joinLeft(array('t2' => $attributeTable), "`t2`.`entity_id`=`t1`.`entity_id`" . " AND `t1`.`entity_type_id`=`t2`.`entity_type_id`" . " AND `t1`.`attribute_id`=`t2`.`attribute_id`" . " AND `t2`.`store_id`={$store}", array($attributeCode => $valueExpr));
     if ($attribute->getFrontend()->getInputType() != 'multiselect' && $hasValueField) {
         $select->joinLeft(array('to1' => $this->getTable('eav/attribute_option_value')), "`to1`.`option_id`={$valueExpr}" . " AND `to1`.`store_id`='0'", array())->joinLeft(array('to2' => $this->getTable('eav/attribute_option_value')), "`to2`.`option_id`={$valueExpr}" . " AND `to2`.`store_id`='{$store}'", array($attributeCode . '_value' => "IFNULL(`to2`.`value`, `to1`.`value`)"));
     }
     $select->where('t1.entity_type_id=?', $attribute->getEntityTypeId())->where('t1.attribute_id=?', $attribute->getId())->where('t1.store_id=?', 0);
     return $select;
 }
예제 #6
0
 public function callbackFilterMotorsSpecificsAttribute(Varien_Data_Collection_Db $collection, $column)
 {
     $value = $column->getFilter()->getValue();
     if ($value == null) {
         return;
     }
     if (!$this->motorsSpecificsAttribute) {
         return;
     }
     $attributeCode = $this->motorsSpecificsAttribute->getAttributeCode();
     if ($value == 1) {
         $collection->addFieldToFilter($attributeCode, array('notnull' => true));
         $collection->addFieldToFilter($attributeCode, array('neq' => '\'\''));
         $collection->addFieldToFilter('is_motors_attribute_in_product_attribute_set', array('notnull' => true));
     } else {
         $collection->addFieldToFilter(array(array('attribute' => $attributeCode, 'null' => true), array('attribute' => $attributeCode, 'eq' => '\'\''), array('attribute' => 'is_motors_attribute_in_product_attribute_set', 'null' => true)));
     }
 }
예제 #7
0
 /**
  * Retrieve Select for update Flat data
  *
  * @param   Mage_Eav_Model_Entity_Attribute_Abstract $attribute
  * @param   int $store
  * @param   bool $hasValueField flag which require option value
  * @return  Varien_Db_Select
  */
 public function getFlatUpdateSelect(Mage_Eav_Model_Entity_Attribute_Abstract $attribute, $store, $hasValueField = true)
 {
     $attributeTable = $attribute->getBackend()->getTable();
     $attributeCode = $attribute->getAttributeCode();
     $joinConditionTemplate = "`e`.`entity_id`=`%s`.`entity_id`" . " AND `%s`.`entity_type_id` = " . $attribute->getEntityTypeId() . " AND `%s`.`attribute_id` = " . $attribute->getId() . " AND `%s`.`store_id` = %d";
     $joinCondition = sprintf($joinConditionTemplate, 't1', 't1', 't1', 't1', Mage_Core_Model_App::ADMIN_STORE_ID);
     if ($attribute->getFlatAddChildData()) {
         $joinCondition .= " AND `e`.`child_id`=`t1`.`entity_id`";
     }
     $valueExpr = new Zend_Db_Expr("IF(t2.value_id>0, t2.value, t1.value)");
     $select = $this->_getReadAdapter()->select()->joinLeft(array('t1' => $attributeTable), $joinCondition, array())->joinLeft(array('t2' => $attributeTable), sprintf($joinConditionTemplate, 't2', 't2', 't2', 't2', $store), array($attributeCode => $valueExpr));
     if ($attribute->getFrontend()->getInputType() != 'multiselect' && $hasValueField) {
         $select->joinLeft(array('to1' => $this->getTable('eav/attribute_option_value')), "`to1`.`option_id`={$valueExpr}" . " AND `to1`.`store_id`='0'", array())->joinLeft(array('to2' => $this->getTable('eav/attribute_option_value')), "`to2`.`option_id`={$valueExpr}" . " AND `to2`.`store_id`='{$store}'", array($attributeCode . '_value' => "IFNULL(`to2`.`value`, `to1`.`value`)"));
     }
     if ($attribute->getFlatAddChildData()) {
         $select->where("e.is_child=?", 0);
     }
     return $select;
 }
예제 #8
0
 public function createIndexData(Mage_Catalog_Model_Product $object, Mage_Eav_Model_Entity_Attribute_Abstract $attribute = null)
 {
     $data = array();
     $data['store_id'] = $attribute->getStoreId();
     $data['entity_id'] = $object->getId();
     $data['attribute_id'] = $attribute->getId();
     $data['value'] = $object->getData($attribute->getAttributeCode());
     if ($attribute->getFrontendInput() == 'multiselect') {
         $origData = $data;
         $data = array();
         $value = explode(',', $origData['value']);
         foreach ($value as $item) {
             $row = $origData;
             $row['value'] = $item;
             $data[] = $row;
         }
     }
     //return $this->_spreadDataForStores($object, $attribute, $data);
     return $data;
 }
 /**
  * Retrieve Select for update Flat data
  *
  * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
  * @param int $store
  * @param bool $hasValueField flag which require option value
  * @return Varien_Db_Select
  */
 public function getFlatUpdateSelect(Mage_Eav_Model_Entity_Attribute_Abstract $attribute, $store, $hasValueField = true)
 {
     $adapter = $this->_getReadAdapter();
     $attributeTable = $attribute->getBackend()->getTable();
     $attributeCode = $attribute->getAttributeCode();
     $joinConditionTemplate = "%s.entity_id = %s.entity_id" . " AND %s.entity_type_id = " . $attribute->getEntityTypeId() . " AND %s.attribute_id = " . $attribute->getId() . " AND %s.store_id = %d";
     $joinCondition = sprintf($joinConditionTemplate, 'e', 't1', 't1', 't1', 't1', Mage_Core_Model_App::ADMIN_STORE_ID);
     if ($attribute->getFlatAddChildData()) {
         $joinCondition .= ' AND e.child_id = t1.entity_id';
     }
     $valueExpr = $adapter->getCheckSql('t2.value_id > 0', 't2.value', 't1.value');
     /** @var $select Varien_Db_Select */
     $select = $adapter->select()->joinLeft(array('t1' => $attributeTable), $joinCondition, array())->joinLeft(array('t2' => $attributeTable), sprintf($joinConditionTemplate, 'e', 't2', 't2', 't2', 't2', $store), array($attributeCode => $valueExpr));
     if ($attribute->getFrontend()->getInputType() != 'multiselect' && $hasValueField) {
         $valueIdExpr = $adapter->getCheckSql('to2.value_id > 0', 'to2.value', 'to1.value');
         $select->joinLeft(array('to1' => $this->getTable('eav/attribute_option_value')), "to1.option_id = {$valueExpr} AND to1.store_id = 0", array())->joinLeft(array('to2' => $this->getTable('eav/attribute_option_value')), $adapter->quoteInto("to2.option_id = {$valueExpr} AND to2.store_id = ?", $store), array($attributeCode . '_value' => $valueIdExpr));
     }
     if ($attribute->getFlatAddChildData()) {
         $select->where("e.is_child = ?", 0);
     }
     return $select;
 }
예제 #10
0
 /**
  * Check whether the attribute is a real field in entity table
  * Rewrited for EAV Collection
  *
  * @param integer|string|Mage_Eav_Model_Entity_Attribute_Abstract $attribute
  * @return bool
  */
 public function isAttributeStatic($attribute)
 {
     $attributeCode = null;
     if ($attribute instanceof Mage_Eav_Model_Entity_Attribute_Interface) {
         $attributeCode = $attribute->getAttributeCode();
     } elseif (is_string($attribute)) {
         $attributeCode = $attribute;
     } elseif (is_numeric($attribute)) {
         $attributeCode = $this->getAttribute($attribute)->getAttributeCode();
     }
     if ($attributeCode) {
         $columns = $this->getAllTableColumns();
         if (in_array($attributeCode, $columns)) {
             return true;
         }
     }
     return false;
 }
예제 #11
0
 /**
  * Returns attributes all values in label-value or value-value pairs form. Labels are lower-cased.
  *
  * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
  * @return array
  */
 public function getAttributeOptions(Mage_Eav_Model_Entity_Attribute_Abstract $attribute)
 {
     $options = array();
     if ($attribute->usesSource()) {
         // should attribute has index (option value) instead of a label?
         $index = in_array($attribute->getAttributeCode(), $this->_indexValueAttributes) ? 'value' : 'label';
         // only default (admin) store values used
         $attribute->setStoreId(Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID);
         try {
             foreach ($attribute->getSource()->getAllOptions(false) as $option) {
                 foreach (is_array($option['value']) ? $option['value'] : array($option) as $innerOption) {
                     if (strlen($innerOption['value'])) {
                         // skip ' -- Please Select -- ' option
                         $options[$innerOption['value']] = $innerOption[$index];
                     }
                 }
             }
         } catch (Exception $e) {
             // ignore exceptions connected with source models
         }
     }
     return $options;
 }
예제 #12
0
 /**
  * Retrieve Select For Flat Attribute update
  *
  * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
  * @param int $storeId
  * @return Varien_Db_Select
  */
 public function getFlatUpdateSelect(Mage_Eav_Model_Entity_Attribute_Abstract $attribute, $storeId)
 {
     $adapter = $this->_getReadAdapter();
     $joinConditionTemplate = "%s.entity_id=%s.entity_id" . " AND %s.entity_type_id = " . $attribute->getEntityTypeId() . " AND %s.attribute_id = " . $attribute->getId() . " AND %s.store_id = %d";
     $joinCondition = sprintf($joinConditionTemplate, 'e', 't1', 't1', 't1', 't1', Mage_Core_Model_App::ADMIN_STORE_ID);
     if ($attribute->getFlatAddChildData()) {
         $joinCondition .= ' AND e.child_id = t1.entity_id';
     }
     $valueExpr = $adapter->getCheckSql('t2.value_id > 0', 't2.value', 't1.value');
     /** @var $select Varien_Db_Select */
     $select = $adapter->select()->joinLeft(array('t1' => $attribute->getBackend()->getTable()), $joinCondition, array())->joinLeft(array('t2' => $attribute->getBackend()->getTable()), sprintf($joinConditionTemplate, 't1', 't2', 't2', 't2', 't2', $storeId), array($attribute->getAttributeCode() => $valueExpr));
     if ($attribute->getFlatAddChildData()) {
         $select->where("e.is_child = ?", 0);
     }
     return $select;
 }
예제 #13
0
 /**
  * Check if attribute is allowed
  *
  * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
  * @param array $attributes
  * @return boolean
  */
 protected function _isAllowedAttribute($attribute, $attributes = null)
 {
     $isAllowed = true;
     if (is_array($attributes) && !(in_array($attribute->getAttributeCode(), $attributes) || in_array($attribute->getAttributeId(), $attributes))) {
         $isAllowed = false;
     }
     return $isAllowed;
 }
예제 #14
0
 /**
  * Set entity attribute value
  *
  * Collect for mass save
  *
  * @param Mage_Core_Model_Abstract $object
  * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
  * @param mixed $value
  * @return Mage_Eav_Model_Entity_Abstract
  */
 protected function _setAttribute($object, $attribute, $value)
 {
     $this->_attributeValuesToSave['$set'][$attribute->getAttributeCode()] = $this->_prepareValueForSave($value, $attribute);
     return $this;
 }
예제 #15
0
 /**
  * Enter description here...
  *
  * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
  * @param Varien_Object $object
  * @return boolean
  */
 public function checkAttributeUniqueValue(Mage_Eav_Model_Entity_Attribute_Abstract $attribute, $object)
 {
     if ($attribute->getBackend()->getType() === 'static') {
         $select = $this->_getWriteAdapter()->select()->from($this->getEntityTable(), $this->getEntityIdField())->where('entity_type_id=?', $this->getTypeId())->where($attribute->getAttributeCode() . '=?', $object->getData($attribute->getAttributeCode()));
     } else {
         $value = $object->getData($attribute->getAttributeCode());
         if ($attribute->getBackend()->getType() == 'datetime') {
             $date = new Zend_Date($value);
             $value = $date->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
         }
         $select = $this->_getWriteAdapter()->select()->from($attribute->getBackend()->getTable(), $attribute->getBackend()->getEntityIdField())->where('entity_type_id=?', $this->getTypeId())->where('attribute_id=?', $attribute->getId())->where('value=?', $value);
     }
     $data = $this->_getWriteAdapter()->fetchCol($select);
     if ($object->getId()) {
         if (isset($data[0])) {
             return $data[0] == $object->getId();
         }
         return true;
     } else {
         return !count($data);
     }
 }
예제 #16
0
 /**
  * Validate attribute value for attributes with source models
  *
  * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
  * @param mixed $attrValue
  * @return array|bool
  */
 protected function _validateAttributeWithSource(Mage_Eav_Model_Entity_Attribute_Abstract $attribute, $attrValue)
 {
     $errors = array();
     // validate attributes with source models
     if (null !== $attrValue && $attribute->getSourceModel()) {
         if ('multiselect' !== $attribute->getFrontendInput() && is_array($attrValue)) {
             return array('Invalid value type for ' . $attribute->getAttributeCode());
         }
         $possibleValues = $attribute->getSource()->getAllOptions(false);
         foreach ((array) $attrValue as $value) {
             if (is_scalar($value)) {
                 $value = (string) $value;
                 $isValid = false;
                 foreach ($possibleValues as $optionData) {
                     // comparison without types check is performed only when both values are numeric
                     $useStrictMode = !(is_numeric($value) && is_numeric($optionData['value']));
                     $isValid = $useStrictMode ? $value === $optionData['value'] : $value == $optionData['value'];
                     if ($isValid) {
                         break;
                     }
                 }
                 if (!$isValid) {
                     $errors[] = 'Invalid value "' . $value . '" for ' . $attribute->getAttributeCode();
                 }
             } else {
                 $errors[] = 'Invalid value type for ' . $attribute->getAttributeCode();
             }
         }
     }
     return $errors ? $errors : true;
 }
예제 #17
0
 /**
  * Check if attribute allowed
  *
  * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
  * @param array $attributes
  * @return boolean
  */
 protected function _isAllowedAttribute($attribute)
 {
     return !in_array($attribute->getFrontendInput(), $this->_ignoredAttributeTypes) && !in_array($attribute->getAttributeCode(), $this->_ignoredAttributeCodes) && $attribute->getFrontendLabel() != "";
 }
예제 #18
0
 /**
  * Enter description here...
  *
  * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
  * @param Varien_Object $object
  * @return boolean
  */
 public function checkAttributeUniqueValue(Mage_Eav_Model_Entity_Attribute_Abstract $attribute, $object)
 {
     if ($attribute->getBackend()->getType() === 'static') {
         $select = $this->_getWriteAdapter()->select()->from($this->getEntityTable(), $this->getEntityIdField())->where('entity_type_id=?', $this->getConfig()->getId())->where($attribute->getAttributeCode() . '=?', $object->getData($attribute->getAttributeCode()));
     } else {
         $select = $this->_getWriteAdapter()->select()->from($attribute->getBackend()->getTable(), $attribute->getBackend()->getEntityIdField())->where('entity_type_id=?', $this->getConfig()->getId())->where('attribute_id=?', $attribute->getId())->where('value=?', $object->getData($attribute->getAttributeCode()));
     }
     $data = $this->_getWriteAdapter()->fetchCol($select);
     if ($object->getId()) {
         if (isset($data[0])) {
             return $data[0] == $object->getId();
         }
         return true;
     } else {
         return !count($data);
     }
 }
예제 #19
0
파일: Sku.php 프로젝트: natxetee/magento2
 /**
  * Return increment needed for SKU uniqueness
  *
  * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
  * @param Mage_Catalog_Model_Product $object
  * @return int
  */
 protected function _getLastSimilarAttributeValueIncrement($attribute, $object)
 {
     $adapter = $this->getAttribute()->getEntity()->getReadConnection();
     $select = $adapter->select();
     $value = $object->getData($attribute->getAttributeCode());
     $bind = array('entity_type_id' => $attribute->getEntityTypeId(), 'attribute_code' => trim($value) . '-%');
     $select->from($this->getTable(), $attribute->getAttributeCode())->where('entity_type_id = :entity_type_id')->where($attribute->getAttributeCode() . ' LIKE :attribute_code')->order(array('entity_id DESC', $attribute->getAttributeCode() . ' ASC'))->limit(1);
     $data = $adapter->fetchOne($select, $bind);
     return abs((int) str_replace($value, '', $data));
 }
예제 #20
0
 /**
  * Returns attributes all values in label-value or value-value pairs form. Labels are lower-cased.
  *
  * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
  * @return array
  */
 public function getAttributeOptions(Mage_Eav_Model_Entity_Attribute_Abstract $attribute)
 {
     $options = array();
     if ($attribute->usesSource()) {
         // should attribute has index (option value) instead of a label?
         $index = in_array($attribute->getAttributeCode(), $this->_indexValueAttributes) ? 'value' : 'label';
         /* MEP changed admin store to current profile store id */
         $attribute->setStoreId($this->getProfile()->getStoreId());
         try {
             foreach ($attribute->getSource()->getAllOptions(false) as $option) {
                 foreach (is_array($option['value']) ? $option['value'] : array($option) as $innerOption) {
                     if (strlen($innerOption['value'])) {
                         // skip ' -- Please Select -- ' option
                         $options[$innerOption['value']] = $innerOption[$index];
                     }
                 }
             }
         } catch (Exception $e) {
             // ignore exceptions connected with source models
         }
     }
     return $options;
 }
 /**
  * Retrieve Select For Flat Attribute update
  *
  * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
  * @param int $store
  * @return Varien_Db_Select
  */
 public function getFlatUpdateSelect(Mage_Eav_Model_Entity_Attribute_Abstract $attribute, $store)
 {
     return $this->_getReadAdapter()->select()->joinLeft(array('t1' => $attribute->getBackend()->getTable()), "`e`.`entity_id`=`t1`.`entity_id` AND `e`.`child_id`=`t1`.`entity_id`", array())->joinLeft(array('t2' => $attribute->getBackend()->getTable()), "t2.entity_id = t1.entity_id" . " AND t1.entity_type_id = t2.entity_type_id" . " AND t1.attribute_id = t2.attribute_id" . " AND t2.store_id = {$store}", array($attribute->getAttributeCode() => "IFNULL(t2.value, t1.value)"))->where("t1.entity_type_id=?", $attribute->getEntityTypeId())->where("t1.attribute_id=?", $attribute->getId())->where("t1.store_id=?", 0)->where("e.is_child=?", 0);
 }
예제 #22
0
 /**
  * Build date element html string for attribute
  *
  * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
  * @param string $part
  * @return string
  */
 public function getDateInput($attribute, $part = 'from')
 {
     $name = $attribute->getAttributeCode() . '[' . $part . ']';
     $value = $this->getAttributeValue($attribute, $part);
     return $this->_getDateBlock()->setName($name)->setId($attribute->getAttributeCode() . ($part == 'from' ? '' : '_' . $part))->setTitle($this->getAttributeLabel($attribute))->setValue($value)->setImage($this->getSkinUrl('Mage_Core::calendar.gif'))->setDateFormat(Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT))->setClass('input-text')->getHtml();
 }
예제 #23
0
파일: Form.php 프로젝트: blazeriaz/youguess
 /**
  * Build date element html string for attribute
  *
  * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
  * @param string $part
  * @return string
  */
 public function getDateInput($attribute, $part = 'from')
 {
     $name = $attribute->getAttributeCode() . '[' . $part . ']';
     $value = $this->getAttributeValue($attribute, $part);
     return $this->_getDateBlock()->setName($name)->setId($attribute->getAttributeCode() . ($part == 'from' ? '' : '_' . $part))->setTitle($this->getAttributeLabel($attribute))->setValue($value)->setImage($this->getSkinUrl('images/calendar.gif'))->setFormat('%m/%d/%y')->setClass('input-text')->getHtml();
 }
예제 #24
0
 /**
  * Retrieve Select For Flat Attribute update
  *
  * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
  * @param int $store
  * @return Varien_Db_Select
  */
 public function getFlatUpdateSelect(Mage_Eav_Model_Entity_Attribute_Abstract $attribute, $store)
 {
     $joinConditionTemplate = "`e`.`entity_id`=`%s`.`entity_id`" . " AND `%s`.`entity_type_id` = " . $attribute->getEntityTypeId() . " AND `%s`.`attribute_id` = " . $attribute->getId() . " AND `%s`.`store_id` = %d";
     $joinCondition = sprintf($joinConditionTemplate, 't1', 't1', 't1', 't1', Mage_Core_Model_App::ADMIN_STORE_ID);
     if ($attribute->getFlatAddChildData()) {
         $joinCondition .= " AND `e`.`child_id`=`t1`.`entity_id`";
     }
     $select = $this->_getReadAdapter()->select()->joinLeft(array('t1' => $attribute->getBackend()->getTable()), $joinCondition, array())->joinLeft(array('t2' => $attribute->getBackend()->getTable()), sprintf($joinConditionTemplate, 't2', 't2', 't2', 't2', $store), array($attribute->getAttributeCode() => "IF(t2.value_id>0, t2.value, t1.value)"));
     if ($attribute->getFlatAddChildData()) {
         $select->where("e.is_child=?", 0);
     }
     return $select;
 }
예제 #25
0
 /**
  * Return if attribute exists in original data array.
  *
  * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
  * @param mixed $value New value of the attribute. Can be used in subclasses.
  * @param array $origData
  * @return bool
  */
 protected function _canUpdateAttribute(Mage_Eav_Model_Entity_Attribute_Abstract $attribute, $v, array &$origData)
 {
     return array_key_exists($attribute->getAttributeCode(), $origData);
 }
예제 #26
0
 /**
  * Retrieve Select For Flat Attribute update
  *
  * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute
  * @param int $store
  * @return Varien_Db_Select
  */
 public function getFlatUpdateSelect(Mage_Eav_Model_Entity_Attribute_Abstract $attribute, $store)
 {
     $joinCondition = "`e`.`entity_id`=`t1`.`entity_id`";
     if ($attribute->getFlatAddChildData()) {
         $joinCondition .= " AND `e`.`child_id`=`t1`.`entity_id`";
     }
     $select = $this->_getReadAdapter()->select()->joinLeft(array('t1' => $attribute->getBackend()->getTable()), $joinCondition, array())->joinLeft(array('t2' => $attribute->getBackend()->getTable()), "t2.entity_id = t1.entity_id" . " AND t1.entity_type_id = t2.entity_type_id" . " AND t1.attribute_id = t2.attribute_id" . " AND t2.store_id = {$store}", array($attribute->getAttributeCode() => "IF(t2.value_id>0, t2.value, t1.value)"))->where("t1.entity_type_id=?", $attribute->getEntityTypeId())->where("t1.attribute_id=?", $attribute->getId())->where("t1.store_id=?", 0);
     if ($attribute->getFlatAddChildData()) {
         $select->where("e.is_child=?", 0);
     }
     return $select;
 }