<commit_before><?php

class Edge_CatalogFilter_Model_Layer_Filter_Category extends Mage_Catalog_Model_Layer_Filter_Category
{
    /**
     * Apply category filter to layer
     *
     * @param   Zend_Controller_Request_Abstract $request
     * @param   Mage_Core_Block_Abstract $filterBlock
     * @return  Mage_Catalog_Model_Layer_Filter_Category
     */
    public function apply(Zend_Controller_Request_Abstract $request, $filterBlock)
    {
        $filter = $request->getParam($this->getRequestVar());
        if (!$filter) {
            return $this;
        }

        if (Mage::getStoreConfig('catalog/layered_navigation/category_filter_type') === Edge_CatalogFilter_Helper_Data::FILTER_TYPE_MULTIPLE) {
            $filters = explode('-', $filter);

            $collectionFilter = array();
            foreach ($filters as $categoryId) {
                $collectionFilter[] = array('finset' => $categoryId);
            }

            $this->getLayer()->getProductCollection()
                ->joinField('category_id', 'catalog/category_product', 'category_id', 'product_id = entity_id', null, 'left')
                ->addAttributeToFilter('category_id', $collectionFilter);

            Mage::getSingleton('catalogfilter/layer_state')->addFilter($this->getRequestVar(), $filters);
        }
        else {

            $category = Mage::getModel('catalog/category')
                ->setStoreId(Mage::app()->getStore()->getId())
                ->load($filter);
            Mage::register('current_category_filter', $category, true);

            $this->getLayer()->getProductCollection()
                ->joinField('category_id', 'catalog/category_product', 'category_id', 'product_id = entity_id', null, 'left')
                ->addAttributeToFilter('category_id', array('eq' => $filter));

            Mage::getSingleton('catalogfilter/layer_state')->addFilter($this->getRequestVar(), $filter);
        }

        return $this;
    }

    /**
     * Initialize filter items
     * @return  Mage_Catalog_Model_Layer_Filter_Abstract
     */
    protected function _initItems()
    {
        $data = $this->_getItemsData();
        $items=array();
        foreach ($data as $itemData) {
            $item = $this->_createItem(
                $itemData['label'],
                $itemData['value'],
                $itemData['count']
            );
            $item->setActive($itemData['active']);
            $items[] = $item;
        }
        $this->_items = $items;
        return $this;
    }
<commit_msg>Group by Product Id on Category Filter<commit_after><?php

class Edge_CatalogFilter_Model_Layer_Filter_Category extends Mage_Catalog_Model_Layer_Filter_Category
{
    /**
     * Apply category filter to layer
     *
     * @param   Zend_Controller_Request_Abstract $request
     * @param   Mage_Core_Block_Abstract $filterBlock
     * @return  Mage_Catalog_Model_Layer_Filter_Category
     */
    public function apply(Zend_Controller_Request_Abstract $request, $filterBlock)
    {
        $filter = $request->getParam($this->getRequestVar());
        if (!$filter) {
            return $this;
        }

        if (Mage::getStoreConfig('catalog/layered_navigation/category_filter_type') === Edge_CatalogFilter_Helper_Data::FILTER_TYPE_MULTIPLE) {
            $filters = explode('-', $filter);

            $collectionFilter = array();
            foreach ($filters as $categoryId) {
                $collectionFilter[] = array('finset' => $categoryId);
            }

            $this->getLayer()->getProductCollection()
                ->joinField('category_id', 'catalog/category_product', 'category_id', 'product_id = entity_id', null, 'left')
                ->addAttributeToFilter('category_id', $collectionFilter);

            Mage::getSingleton('catalogfilter/layer_state')->addFilter($this->getRequestVar(), $filters);
        }
        else {

            $category = Mage::getModel('catalog/category')
                ->setStoreId(Mage::app()->getStore()->getId())
                ->load($filter);
            Mage::register('current_category_filter', $category, true);

            $this->getLayer()->getProductCollection()
                ->joinField('category_id', 'catalog/category_product', 'category_id', 'product_id = entity_id', null, 'left')
                ->addAttributeToFilter('category_id', array('eq' => $filter));

            $this->getLayer()->getProductCollection()->getSelect()->group('e.entity_id');

            Mage::getSingleton('catalogfilter/layer_state')->addFilter($this->getRequestVar(), $filter);
        }

        return $this;
    }

    /**
     * Initialize filter items
     * @return  Mage_Catalog_Model_Layer_Filter_Abstract
     */
    protected function _initItems()
    {
        $data = $this->_getItemsData();
        $items=array();
        foreach ($data as $itemData) {
            $item = $this->_createItem(
                $itemData['label'],
                $itemData['value'],
                $itemData['count']
            );
            $item->setActive($itemData['active']);
            $items[] = $item;
        }
        $this->_items = $items;
        return $this;
    }

{'fraction_non_alphanumeric': 0.13829787234042554, 'fraction_numerical': 0.0, 'mean_word_length': 2.4986468200270635, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3633001', 'n_tokens_mistral': 1423, 'n_tokens_neox': 1393, 'n_words': 219}