<?php

namespace KupShop\ElninoBundle\AdWords\GroupType;

use Query\Filter;

class ProducerGroupType extends AbstractGroupType
{
    protected $type = 'manufacturer';

    public function getProductsQueryset(&$match)
    {
        $qb = parent::getProductsQueryset($match);

        $parameter = translate_template('kategorie');
        if (!empty($match[$parameter])) {
            $match['type'] = 'categoryManufacturer';
        }

        $parameter = translate_template('rada');
        if (!empty($match[$parameter])) {
            $match['type'] = 'serie';
        }

        $qb->andWhere(Filter::byProducers([$match['id_producer']]));

        return $qb;
    }
}
