src/Backend/Modules/Commerce/Domain/Product/ProductRepository.php
/**
     * Filter the products based on specification values.
     */
Filter the products based on specification values.
Filter the products based on specification values .
public function filterProducts(array $filters, Category $category, int $limit, int $offset, string $sorting): array
    {
        $sql = 'SELECT p.* FROM commerce_products p WHERE p.categoryId = :category AND p.hidden = :hidden';
        $parameters = [
            'category' => $category,
            'hidden' => false,
        ];
        $this->buildFilterQuery($sql, $parameters, $filters);
        $this->setProductSorting($sql, $sorting);
        $sql .= ' LIMIT ' . $offset . ', ' . $limit;
        $rsm = new ResultSetMappingBuilder($this->getEntityManager());
        $rsm->addRootEntityFromClassMetadata(Product::class, 'p');
        $query = $this->getEntityManager()->createNativeQuery($sql, $rsm);
        $query->setParameters($parameters);
        return $query->getResult();
    }
public function filterProducts ( array $ filters , Category $ category , int $ limit , int $ offset , string $ sorting ) : array { $ sql = 'SELECT p.* FROM commerce_products p WHERE p.categoryId = :category AND p.hidden = :hidden' ; $ parameters = [ 'category' => $ category , 'hidden' => false , ] ; $ this -> buildFilterQuery ( $ sql , $ parameters , $ filters ) ; $ this -> setProductSorting ( $ sql , $ sorting ) ; $ sql .= ' LIMIT ' . $ offset . ', ' . $ limit ; $ rsm = new ResultSetMappingBuilder ( $ this -> getEntityManager ( ) ) ; $ rsm -> addRootEntityFromClassMetadata ( Product :: class , 'p' ) ; $ query = $ this -> getEntityManager ( ) -> createNativeQuery ( $ sql , $ rsm ) ; $ query -> setParameters ( $ parameters ) ; return $ query -> getResult ( ) ; }
Filter the products based on specification values.
Filter the products based on specification values .