Index: branches/5.2.x/units/manufacturers/manufacturers_event_handler.php =================================================================== diff -u -N -r14677 -r14986 --- branches/5.2.x/units/manufacturers/manufacturers_event_handler.php (.../manufacturers_event_handler.php) (revision 14677) +++ branches/5.2.x/units/manufacturers/manufacturers_event_handler.php (.../manufacturers_event_handler.php) (revision 14986) @@ -1,6 +1,6 @@ Array('self' => true), ); @@ -37,40 +41,43 @@ * @access protected * @see kDBEventHandler::OnListBuild() */ - protected function SetCustomQuery(&$event) + protected function SetCustomQuery(kEvent &$event) { - if ($this->Application->isAdminUser) { - return ; + parent::SetCustomQuery($event); + + if ( $this->Application->isAdminUser ) { + return; } $category_id = $this->Application->GetVar('m_cat_id'); $parent_category_id = $event->getEventParam('parent_cat_id'); - if ($parent_category_id) { - if ($parent_category_id != 'any' && $parent_category_id > 0) { + if ( $parent_category_id ) { + if ( $parent_category_id != 'any' && $parent_category_id > 0 ) { $category_id = $parent_category_id; } } $sql = 'SELECT m.ManufacturerId, COUNT(p.ProductId) - FROM '.TABLE_PREFIX.'Manufacturers m - LEFT JOIN '.TABLE_PREFIX.'Products p ON p.ManufacturerId = m.ManufacturerId - LEFT JOIN '.TABLE_PREFIX.'CategoryItems ci ON ci.ItemResourceId = p.ResourceId - LEFT JOIN '.TABLE_PREFIX.'Category c ON c.CategoryId = ci.CategoryId + FROM ' . TABLE_PREFIX . 'Manufacturers m + LEFT JOIN ' . TABLE_PREFIX . 'Products p ON p.ManufacturerId = m.ManufacturerId + LEFT JOIN ' . TABLE_PREFIX . 'CategoryItems ci ON ci.ItemResourceId = p.ResourceId + LEFT JOIN ' . TABLE_PREFIX . 'Category c ON c.CategoryId = ci.CategoryId WHERE (ci.PrimaryCat = 1) AND (p.Status = ' . STATUS_ACTIVE . ') AND (c.Status = ' . STATUS_ACTIVE . ') GROUP BY m.ManufacturerId'; // add category filter $tree_indexes = $this->Application->getTreeIndex($category_id); // if category_id is 0 returs false - if ($tree_indexes) { - $sql .= ' AND c.TreeLeft BETWEEN '.$tree_indexes['TreeLeft'].' AND '.$tree_indexes['TreeRight']; + if ( $tree_indexes ) { + $sql .= ' AND c.TreeLeft BETWEEN ' . $tree_indexes['TreeLeft'] . ' AND ' . $tree_indexes['TreeRight']; } $manufacturers = $this->Conn->GetCol($sql); $object =& $event->getObject(); + /* @var $object kDBList */ $object->addFilter('category_manufacturer_filter', $manufacturers ? '%1$s.ManufacturerId IN (' . implode(',', $manufacturers) . ')' : 'FALSE'); }