Маженто 1.3
В каталоге при просмотре категории необходимо добавить и вывести аттрибут.
Есть такой блок
class Pro_CatalogProduct_Block_List extends Mage_Catalog_Block_Product_List { protected function _getProductCollection() { if (is_null($this->_productCollection)) { $this->_productCollection = Mage::getModel('catalog/product')->getCollection(); $attributes = Mage::getSingleton('catalog/config') ->getProductAttributes(); Zend_Debug::dump($attributes); $this->_productCollection->addAttributeToSelect($attributes) ->addMinimalPrice() ->addFinalPrice() ->addTaxPercents(); $this->_productCollection->joinField( 'qty', 'cataloginventory/stock_item', 'qty', 'product_id=entity_id', '{{table}}.qty = 0 AND {{table}}.is_in_stock=0' ); // пытаюсь добавить и вывести нужный аттрибут $this->_productCollection->joinAttribute('codefamille', 'catalog_product/codefamille', 'entity_id', null, 'left'); } return $this->_productCollection; } }
В итоговом sql есть ошибка
LEFT JOIN `catalog_product_entity_varchar` AS `_table_codefamille_default` ON (_table_codefamille_default.entity_id = e.) AND (_table_codefamille_default.attribute_id='1029') AND _table_codefamille_default.store_id=0 LEFT JOIN `catalog_product_entity_varchar` AS `_table_codefamille` ON (_table_codefamille.entity_id = e.) AND (_table_codefamille.attribute_id='1029') AND (_table_codefamille.store_id='5')
(_table_codefamille.entity_id = e.)
Как исправить не пойму, может я не правильно что то делаю.
Весь sql
SELECT 1 AS `status`, `e`.`entity_id`, `e`.`type_id`, `e`.`attribute_set_id`, `e`.`name`, `e`.`price`, `e`.`small_image`, `e`.`tax_class_id`, `e`.`url_key`, `e`.`thumbnail`, `e`.`short_description`, `e`.`special_price`, `e`.`special_from_date`, `e`.`special_to_date`, `e`.`news_from_date`, `e`.`news_to_date`, `e`.`required_options`, `e`.`price_type`, `e`.`weight_type`, `e`.`price_view`, `e`.`shipment_type`, `e`.`image_label`, `e`.`small_image_label`, `e`.`thumbnail_label`, `e`.`neufoccasion`, `e`.`atttest`, `e`.`ventes`, `e`.`typeguide`, `e`.`guidenumerique`, `e`.`issue`, `e`.`slug`, `e`.`year`, `e`.`version_simple`, `e`.`price`, `e`.`special_price`, `e`.`special_from_date`, `e`.`special_to_date`, `_table_qty`.`qty`, IFNULL(_table_codefamille.value, _table_codefamille_default.value) AS `codefamille`, `e`.`display_price_group_1` AS `_rule_price` FROM `catalog_product_flat_5` AS `e` INNER JOIN `cataloginventory_stock_item` AS `_table_qty` ON (_table_qty.product_id=e.entity_id) AND (_table_qty.qty = 0 AND _table_qty.is_in_stock=0) LEFT JOIN `catalog_product_entity_varchar` AS `_table_codefamille_default` ON (_table_codefamille_default.entity_id = e.) AND (_table_codefamille_default.attribute_id='1029') AND _table_codefamille_default.store_id=0 LEFT JOIN `catalog_product_entity_varchar` AS `_table_codefamille` ON (_table_codefamille.entity_id = e.) AND (_table_codefamille.attribute_id='1029') AND (_table_codefamille.store_id='5') ORDER BY `e`.`ventes` asc
Спасибо!