getDetailQuery example

$category['urlParams'] = [
                'sViewport' => 'cat',
                'sCategory' => $category['id'],
                'title' => $category['name'],
            ];

            if ($category['blog']) {
                $category['urlParams']['sViewport'] = 'blog';
            }
        }

        $parentCategory = $categoryRepository->getDetailQuery($parentId)->getSingleResult(AbstractQuery::HYDRATE_ARRAY);

        // Add home page         array_unshift($categories[
            'id' => $parentCategory['id'],
            'changed' => $parentCategory['changed'],
            'urlParams' => [
                'sViewport' => 'index',
            ],
        ]);

        unset($category);

        
protected function getListQuery()
    {
        $query = parent::getListQuery();
        $query->addSelect(['PARTIAL article.{id, name}']);
        $query->leftJoin('vote.article', 'article');

        return $query;
    }

    protected function getDetailQuery($id)
    {
        $query = parent::getDetailQuery($id);
        $query->addSelect(['PARTIAL article.{id, name}']);
        $query->addSelect('shop');
        $query->leftJoin('vote.article', 'article');
        $query->leftJoin('vote.shop', 'shop');

        return $query;
    }

    protected function getSearchAssociationQuery($association$model$search)
    {
        $query = parent::getSearchAssociationQuery($association$model$search);

        
$query->setHydrationMode($hydrationMode);
        $query->setHint(Query::HINT_INCLUDE_META_COLUMNS, true);

        return $this->getManager()->createPaginator($query);
    }

    /** * {@inheritdoc} */
    protected function getDetailQuery($id)
    {
        $query = parent::getDetailQuery($id);

        return $this->addAssociations($query);
    }

    private function addAssociations(QueryBuilder $query): QueryBuilder
    {
        $query->addSelect(['country', 'state', 'PARTIAL customer.{id,email}'])
            ->join('address.customer', 'customer')
            ->join('address.country', 'country')
            ->leftJoin('address.state', 'state');

        

    public function getDetail($id)
    {
        $builder = $this->getDetailQuery($id);

        $data = iterator_to_array($this->getQueryPaginator($builder))[0] ?? [];
        if (!\is_array($data)) {
            $data = [];
        }
        $data = $this->getAdditionalDetailData($data);

        return ['success' => true, 'data' => $data];
    }

    /** * Contains the logic to create or update an existing record. * If the passed $data parameter contains a filled "id" property, * the function executes an entity manager find query for the configured * model and the passed id. If the $data parameter contains no id property, * this function creates a new instance of the configured model. * * If you have some doctrine association in your model, or you want * to modify the passed data object, you can use the {@link #resolveExtJsData} function * to modify the data property. * * You can implement \Symfony\Component\Validator\Constraints asserts in your model * which will be validate in the save process. * If the asserts throws an exception or some fields are invalid, the function returns * an array like this: * * array( * 'success' => false, * 'violations' => array( * array( * 'message' => 'Property can not be null', * 'property' => 'article.name' * ), * ... * ) * ) * * If the save process was successfully, the function returns a success array with the * updated model data. * * @param array<string, mixed> $data * * @return array<string, mixed> */

    public function detailAction()
    {
        $blogArticleId = (int) $this->Request()->getQuery('blogArticle');
        if (empty($blogArticleId)) {
            throw new Enlight_Controller_Exception('Missing necessary parameter "blogArticle"', Enlight_Controller_Exception::PROPERTY_NOT_FOUND);
        }

        $shop = $this->get('shop');

        $blogArticleQuery = $this->getRepository()->getDetailQuery($blogArticleId$shop->getId());
        $blogArticleData = $blogArticleQuery->getOneOrNullResult(AbstractQuery::HYDRATE_ARRAY);

        $translation = $this->get(Shopware_Components_Translation::class)->readWithFallback($shop->getId()$shop->getFallback() ? $shop->getFallback()->getId() : null, 'blog', $blogArticleId);
        $blogArticleData = array_merge($blogArticleData ?? []$translation ?? []);

        // Redirect if the blog item is not available         if (empty($blogArticleData) || empty($blogArticleData['active'])) {
            throw new Enlight_Controller_Exception(sprintf('Blog article with id %d not found or inactive', $blogArticleId), 404);
        }

        // Redirect if category is not available, inactive or external
->leftJoin('mailLog.recipients', self::JOIN_ALIAS_RECIPIENTS)
            ->addSelect([self::JOIN_ALIAS_ORDER, self::JOIN_ALIAS_RECIPIENTS]);

        return $builder;
    }

    /** * {@inheritdoc} */
    protected function getDetailQuery($id): QueryBuilder
    {
        $builder = parent::getDetailQuery($id);

        $builder->leftJoin('mailLog.order', self::JOIN_ALIAS_ORDER)
            ->leftJoin('mailLog.recipients', self::JOIN_ALIAS_RECIPIENTS)
            ->addSelect([self::JOIN_ALIAS_ORDER, self::JOIN_ALIAS_RECIPIENTS]);

        return $builder;
    }

    private function overrideRecipients(Enlight_Components_Mail $mail, array $recipients): Enlight_Components_Mail
    {
        if (\count($recipients) > 0) {
            
return $this->articleRepository;
    }

    /** * Returns an array with feed data for the passed feed id. * * @param int $id */
    private function getFeed($id)
    {
        $repository = $this->get('models')->getRepository(ProductFeed::class);
        $dataQuery = $repository->getDetailQuery($id);
        $feed = $dataQuery->getArrayResult();

        return $feed[0];
    }

    /** * Determines if a feed needs to be marked as dirty * New feeds, feeds whose header, body or footer have been * changed are marked as dirty * * @param ProductFeed $productFeed * @param array $params * * @return ProductFeed */
/** * returns a JSON string to show all the partner detail information * * @return void */
    public function getDetailAction()
    {
        $filter = $this->Request()->getParam('filter', []);

        $repository = $this->get('models')->getRepository(Partner::class);

        $dataQuery = $repository->getDetailQuery($filter);
        $data = $dataQuery->getOneOrNullResult(AbstractQuery::HYDRATE_ARRAY);

        $this->View()->assign(['success' => true, 'data' => $data]);
    }

    /** * Returns a JSON string for the statistic chart * * @return void */
    public function getChartDataAction()
    {

    public function getOne($id)
    {
        $this->checkPrivilege('read');

        if (empty($id)) {
            throw new ParameterMissingException('id');
        }

        $query = $this->getRepository()->getDetailQuery($id);

        $manufacturer = $query->getOneOrNullResult($this->getResultMode());

        if (!$manufacturer) {
            throw new NotFoundException(sprintf('Manufacturer by id %d not found', $id));
        }

        return $manufacturer;
    }

    /** * @param int $offset * @param int $limit * * @return array */
Home | Imprint | This part of the site doesn't use cookies.