buildFilters example

$display_options['fields']['title']['plugin_id'] = 'field';
        break;
    }
  }

  /** * Overrides Drupal\views\Plugin\views\wizard\WizardPluginBase::buildFilters(). * * Add some options for filter by taxonomy terms. */
  protected function buildFilters(&$form, FormStateInterface $form_state) {
    parent::buildFilters($form$form_state);

    if (isset($form['displays']['show']['type'])) {
      $selected_bundle = static::getSelected($form_state['show', 'type'], 'all', $form['displays']['show']['type']);
    }

    // Add the "tagged with" filter to the view.
    // We construct this filter using taxonomy_index.tid (which limits the     // filtering to a specific vocabulary) rather than     // taxonomy_term_field_data.name (which matches terms in any vocabulary).     // This is because it is a more commonly-used filter that works better with

                        ],
                    ],
                ],
            ],
        ];

        $this->getContainer()->get('product_stream.repository')
            ->create([$stream], Context::createDefaultContext());

        $filters = $this->getContainer()->get(ProductStreamBuilder::class)
            ->buildFilters($ids->get('stream'), Context::createDefaultContext());

        $expected = new MultiFilter(MultiFilter::CONNECTION_OR, [
            new MultiFilter(MultiFilter::CONNECTION_AND, [
                new ContainsFilter('product.name', 'Awesome'),
                new NotFilter(MultiFilter::CONNECTION_AND, [
                    new ContainsFilter('product.name', 'Copper'),
                ]),
            ]),
        ]);

        $filter = array_shift($filters);
        
$productExport->getCurrencyId()
            )
        );

        $this->translator->injectSettings(
            $productExport->getStorefrontSalesChannelId(),
            $productExport->getSalesChannelDomain()->getLanguageId(),
            $this->languageLocaleProvider->getLocaleForLanguageId($productExport->getSalesChannelDomain()->getLanguageId()),
            $context->getContext()
        );

        $filters = $this->productStreamBuilder->buildFilters(
            $productExport->getProductStreamId(),
            $context->getContext()
        );

        $associations = $this->getAssociations($productExport$context);

        $criteria = new Criteria();
        $criteria->setTitle('product-export::products');

        $criteria
            ->addFilter(...$filters)
            
->search($criteria$context->getContext())
            ->getEntities();

        return $crossSellings;
    }

    private function loadByStream(ProductCrossSellingEntity $crossSelling, SalesChannelContext $context, Criteria $criteria): CrossSellingElement
    {
        /** @var string $productStreamId */
        $productStreamId = $crossSelling->getProductStreamId();

        $filters = $this->productStreamBuilder->buildFilters(
            $productStreamId,
            $context->getContext()
        );

        $criteria->addFilter(...$filters)
            ->setOffset(0)
            ->setLimit($crossSelling->getLimit())
            ->addSorting($crossSelling->getSorting());

        $criteria = $this->handleAvailableStock($criteria$context);

        
$result->setStreamId($category->get('productStreamId'));

        return new ProductListingRouteResponse($result);
    }

    private function extendCriteria(SalesChannelContext $salesChannelContext, Criteria $criteria, PartialEntity $category): void
    {
        $hasProductStream = $category->get('productAssignmentType') === CategoryDefinition::PRODUCT_ASSIGNMENT_TYPE_PRODUCT_STREAM
            && $category->get('productStreamId') !== null;

        if ($hasProductStream) {
            $filters = $this->productStreamBuilder->buildFilters(
                $category->get('productStreamId'),
                $salesChannelContext->getContext()
            );
            $criteria->addFilter(...$filters);

            return;
        }

        $criteria->addFilter(
            new EqualsFilter('product.categoriesRo.id', $category->getId())
        );
    }


  /** * {@inheritdoc} */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $style_options = Views::fetchPluginNames('style', 'normal', [$this->base_table]);
    $feed_row_options = Views::fetchPluginNames('row', 'feed', [$this->base_table]);
    $path_prefix = Url::fromRoute('<none>', []['absolute' => TRUE])->toString();

    // Add filters and sorts which apply to the view as a whole.     $this->buildFilters($form$form_state);
    $this->buildSorts($form$form_state);

    $form['displays']['page'] = [
      '#type' => 'fieldset',
      '#title' => $this->t('Page settings'),
      '#attributes' => ['class' => ['views-attachment', 'fieldset-no-legend']],
      '#tree' => TRUE,
    ];
    $form['displays']['page']['create'] = [
      '#title' => $this->t('Create a page'),
      '#type' => 'checkbox',
      


        $criteria->addAssociation('cover');
        $criteria->addAssociation('options.group');
        $criteria->addAssociation('manufacturer');

        return $criteria;
    }

    private function collectByProductStream(ResolverContext $resolverContext, FieldConfig $config, FieldConfigCollection $elementConfig): Criteria
    {
        $filters = $this->productStreamBuilder->buildFilters(
            $config->getStringValue(),
            $resolverContext->getSalesChannelContext()->getContext()
        );

        $sorting = 'name:' . FieldSorting::ASCENDING;
        $productStreamSorting = $elementConfig->get('productStreamSorting');
        if ($productStreamSorting !== null) {
            $sorting = $productStreamSorting->getStringValue();
        }
        $limit = self::FALLBACK_LIMIT;
        $productStreamLimit = $elementConfig->get('productStreamLimit');
        
Home | Imprint | This part of the site doesn't use cookies.