/** * Retrieve select object for loading entity attributes values * * Join attribute store value * * @param Varien_Object $object * @param mixed $rowId * @return Zend_Db_Select */ protected function _getLoadAttributesSelect($object, $table) { /** * This condition is applicable for all cases when we was work in not single * store mode, customize some value per specific store view and than back * to single store mode. We should load correct values */ if (Mage::app()->isSingleStoreMode()) { $storeId = Mage::app()->getStore(true)->getId(); } else { $storeId = $object->getStoreId(); } $select = $this->_read->select()->from(array('default' => $table)); if ($setId = $object->getAttributeSetId()) { $select->join(array('set_table' => $this->getTable('eav/entity_attribute')), 'default.attribute_id=set_table.attribute_id AND ' . 'set_table.attribute_set_id=' . intval($setId), array()); } $joinCondition = 'main.attribute_id=default.attribute_id AND ' . $this->_read->quoteInto('main.store_id=? AND ', intval($storeId)) . $this->_read->quoteInto('main.' . $this->getEntityIdField() . '=?', $object->getId()); $select->joinLeft(array('main' => $table), $joinCondition, array('store_value_id' => 'value_id', 'store_value' => 'value'))->where('default.' . $this->getEntityIdField() . '=?', $object->getId())->where('default.store_id=?', $this->getDefaultStoreId()); return $select; }
/** * Retrieve select object for loading entity attributes values * Join attribute store value * * @param Varien_Object $object * @param string $table * @return Varien_Db_Select */ protected function _getLoadAttributesSelect($object, $table) { /** * This condition is applicable for all cases when we was work in not single * store mode, customize some value per specific store view and than back * to single store mode. We should load correct values */ if (Mage::app()->isSingleStoreMode()) { $storeId = (int) Mage::app()->getStore(true)->getId(); } else { $storeId = (int) $object->getStoreId(); } $setId = $object->getAttributeSetId(); $storeIds = array($this->getDefaultStoreId()); if ($storeId != $this->getDefaultStoreId()) { $storeIds[] = $storeId; } $select = $this->_getReadAdapter()->select()->from(array('attr_table' => $table), array())->where("attr_table.{$this->getEntityIdField()} = ?", $object->getId())->where('attr_table.store_id IN (?)', $storeIds); if ($setId) { $select->join(array('set_table' => $this->getTable('eav/entity_attribute')), $this->_getReadAdapter()->quoteInto('attr_table.attribute_id = set_table.attribute_id' . ' AND set_table.attribute_set_id = ?', $setId), array()); } return $select; }
/** * Get codes of all entity type attributes * * @param mixed $entityType * @param Varien_Object $object * @return array */ public function getEntityAttributeCodes($entityType, $object = null) { $entityType = $this->getEntityType($entityType); $attributeSetId = 0; if ($object instanceof Varien_Object && $object->getAttributeSetId()) { $attributeSetId = $object->getAttributeSetId(); } $storeId = 0; if ($object instanceof Varien_Object && $object->getStoreId()) { $storeId = $object->getStoreId(); } $cacheKey = sprintf('%d-%d', $entityType->getId(), $attributeSetId); if (isset($this->_attributeCodes[$cacheKey])) { return $this->_attributeCodes[$cacheKey]; } if ($attributeSetId) { $attributesInfo = Mage::getResourceModel($entityType->getEntityAttributeCollection())->setEntityTypeFilter($entityType)->setAttributeSetFilter($attributeSetId)->addStoreLabel($storeId)->getData(); $attributes = array(); foreach ($attributesInfo as $attributeData) { $attributes[] = $attributeData['attribute_code']; $this->_createAttribute($entityType, $attributeData); } } else { $this->_initAttributes($entityType); $attributes = $this->getEntityType($entityType)->getAttributeCodes(); } $this->_attributeCodes[$cacheKey] = $attributes; return $attributes; }
/** * @param Varien_Object $params * @return void */ protected function _redirectToIndex(Varien_Object $params) { $this->_redirect('*/*/index', array('attribute_set_id' => $params->getAttributeSetId(), 'mapping_product_type_id' => $params->getMappingProductTypeId())); }
/** * @param Varien_Object $product * @return null */ protected function _getProductTypeId(Varien_Object $product) { $productTypeId = Mage::getResourceModel('xcom_mapping/product_type')->getProductTypeId($product->getAttributeSetId()); return $productTypeId ? $productTypeId : null; }