Jump to content

Recommended Posts

Hello !

I'm trying to modify Manufacturer query for admin page in presta 1.7.6.

For this i use this hook in order to alter $params['search_query_builder'].

 public function hookActionManufacturerGridQueryBuilderModifier($params)

Its easy to add something into the query , but i'm trying to remove this  select that is in the core. (ManufacturerQueryBuilder)

addSelect('(' . $addressesQb->getSQL() . ') AS addresses_count')

into the function

 public function getSearchQueryBuilder(SearchCriteriaInterface $searchCriteria)
    {
        $addressesQb = $this->connection->createQueryBuilder();
        $addressesQb->select('COUNT(a.`id_manufacturer`) AS `addresses_count`')
            ->from($this->dbPrefix . 'address', 'a')
            ->where('m.`id_manufacturer` = a.`id_manufacturer`')
            ->andWhere('a.`deleted` = 0')
            ->groupBy('a.`id_manufacturer`')
        ;

        $qb = $this->getQueryBuilder($searchCriteria->getFilters());
        $qb
            ->select('m.`id_manufacturer`, m.`name`, m.`active`')
            ->addSelect('COUNT(p.`id_product`) AS `products_count`')
            ->addSelect('(' . $addressesQb->getSQL() . ') AS addresses_count')
            ->groupBy('m.`id_manufacturer`')
        ;

        $this->searchCriteriaApplicator
            ->applyPagination($searchCriteria, $qb)
            ->applySorting($searchCriteria, $qb)
        ;

        return $qb;
    }

Does anybody has already made this ?

thanks a lot for ur help

Link to comment
Share on other sites

  • 2 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...