/** * @param string $method the query builder creation method * @param array $config the query builder creation config * * @return Datasource */ protected function initializeQueryBuilder($method, array $config = []) { $factoryConfig['repository_parameters'] = $config; $factoryConfig['repository_method'] = $method; $factoryConfig['default_locale'] = $this->getConfiguration('locale_code'); $factoryConfig['default_scope'] = $this->getConfiguration('scope_code'); $this->pqb = $this->factory->create($factoryConfig); $this->qb = $this->pqb->getQueryBuilder(); return $this; }
/** * Applies categorization filter * * @param ProductQueryBuilderInterface $pqb * @param ChannelInterface $channel */ protected function applyCategorizationFilter(ProductQueryBuilderInterface $pqb, ChannelInterface $channel) { switch ($this->categorizationCondition) { case "onlyCategorized": $pqb->addFilter('categories.id', 'IN CHILDREN', [$channel->getCategory()->getId()]); break; case "onlyNonCategorized": $pqb->addFilter('categories.id', 'UNCLASSIFIED', []); break; } }
/** * Apply complete filter * * @param ProductQueryBuilderInterface $pqb * @param ChannelInterface $channel */ protected function applyCompleteFilter(ProductQueryBuilderInterface $pqb, ChannelInterface $channel) { switch ($this->completeCondition) { case "onlyComplete": $pqb->addFilter('completeness_for_export', '=', 100, ['scope' => $channel->getCode()]); break; case "onlyUncomplete": $pqb->addFilter('completeness_for_export', '<', 100, ['scope' => $channel->getCode()]); break; } }