SearchCriteria example

'orders' => $this->getOrders($term),
        ];
    }

    /** * @param string $term * * @return array */
    private function getArticles($term)
    {
        $criteria = new SearchCriteria(Article::class);
        $criteria->term = $term;
        $criteria->limit = 5;

        $result = $this->productRepository->search($criteria);

        return $result->getData();
    }

    /** * @param string $term * * @return array */
break;
                }
            }
        }

        return ['data' => $sortedData, 'total' => $result->getCount()];
    }

    private function createCriteria(Enlight_Controller_Request_Request $request): SearchCriteria
    {
        if ($request->getParam('showVariants', false) === 'true') {
            $criteria = new SearchCriteria(Detail::class);
        } else {
            $criteria = new SearchCriteria(Article::class);
        }
        $criteria->offset = $request->getParam('start', 0);
        $criteria->limit = $request->getParam('limit', 30);
        $criteria->ids = $request->getParam('ids', []);
        $criteria->term = $request->getParam('query', null);
        $criteria->sortings = $request->getParam('sort', []);
        $criteria->conditions = $request->getParam('filters', []);

        $categoryId = (int) $request->getParam('categoryId', 0);

        
$query->setParameter(':ids', $ids, Connection::PARAM_INT_ARRAY);

        return $query->getQuery()->getArrayResult();
    }

    /** * @return array{success: true, data: array<array<string, mixed>>, total: int} */
    private function loadFromRepository(): array
    {
        $request = $this->Request();
        $criteria = new SearchCriteria(Customer::class);
        $criteria->offset = (int) $request->getParam('start', 0);
        $criteria->limit = (int) $request->getParam('limit', 30);
        $criteria->term = $request->getParam('query', null);
        $criteria->sortings = $request->getParam('sort', []);
        $criteria->conditions = $request->getParam('filter', []);

        foreach ($criteria->sortings as &$sorting) {
            switch ($sorting['property']) {
                case 'customerGroup':
                    $sorting['property'] = 'customerGroupId';
                    break;
                
/** * @param int|null $offset * @param int|null $limit * * @throws Exception * * @return array */
    private function getManufacturerIds($offset = null, $limit = null)
    {
        $criteria = new SearchCriteria(Supplier::class);
        $registry = Shopware()->Container()->get('shopware_attribute.repository_registry');
        $repo = $registry->getRepository($criteria);

        if ($offset !== null) {
            $criteria->offset = $offset;
        }

        $criteria->limit = $limit;
        $result = $repo->search($criteria);
        $suppliers = $result->getData();

        
return null;
        }
        stream_copy_to_stream($source$downstream);

        return $tmpFile;
    }

    private function createCriteria(): SearchCriteria
    {
        $request = $this->Request();
        $criteria = new SearchCriteria(Order::class);

        $criteria->offset = $request->getParam('start', 0);
        $criteria->limit = $request->getParam('limit', 30);
        $criteria->ids = $request->getParam('ids', []);
        $criteria->sortings = $request->getParam('sort', []);
        $conditions = $request->getParam('filter', []);
        $orderId = (int) $this->Request()->getParam('orderID');
        if ($orderId !== 0) {
            $criteria->ids[] = $orderId;
        }

        
'success' => true,
                'data' => array_values($result->getData()),
                'total' => $result->getCount(),
            ]);
        } catch (Exception $e) {
            $this->View()->assign(['success' => true, 'message' => $e->getMessage()]);
        }
    }

    private function createCriteria(Request $request): SearchCriteria
    {
        $criteria = new SearchCriteria($request->getParam('model'));
        $criteria->offset = $request->getParam('start', 0);
        $criteria->limit = $request->getParam('limit', 30);
        $criteria->ids = $request->getParam('ids', []);
        $criteria->term = $request->getParam('query');
        $criteria->sortings = $request->getParam('sorts', $this->Request()->getParam('sort', []));
        $criteria->conditions = $request->getParam('filters', []);

        $filters = $request->getParam('filter', []);
        if (empty($criteria->conditions) && !empty($filters)) {
            $criteria->conditions = $filters;
        }

        
if (empty($backlogs)) {
            $output->writeln('Backlog empty');

            return 0;
        }

        $registry = $this->container->get('shopware_attribute.repository_registry');

        $indexer = $this->container->get('shopware_es_backend.indexer');

        foreach ($backlogs as $backlog) {
            $criteria = new SearchCriteria($backlog['entity']);

            $repository = $registry->getRepository($criteria);

            if (!$repository instanceof EsAwareRepository) {
                continue;
            }

            $output->writeln(sprintf('Sync %s with id %s', $backlog['entity']$backlog['entity_id']));

            if ($backlog['entity'] === Article::class) {
                $this->indexArticle($backlog['entity_id']);
            }
Home | Imprint | This part of the site doesn't use cookies.