findEntityByConditions example

$query = $this->getManager()->createQuery('SELECT shop FROM Shopware\Models\Shop\Shop as shop');

            foreach ($query->getArrayResult() as $shop) {
                $translation = $this->translationComponent->read($shop['id'], 'article', $id);
                if (!empty($translation)) {
                    $translation['shopId'] = $shop['id'];
                    $product['translations'][$shop['id']] = $translation;
                }
            }

            if (isset($options['language']) && !empty($options['language'])) {
                $shop = $this->findEntityByConditions(Shop::class[
                    ['id' => $options['language']],
                    ['shop' => $options['language']],
                ]);
                if (!$shop instanceof Shop) {
                    throw new ModelNotFoundException(Shop::class$options['language']);
                }

                $product = $this->translateArticle($product$shop);
            }
        }

        

    protected function getProductIdByNumber($number)
    {
        $entity = $this->findEntityByConditions(
            Detail::class,
            [['number' => $number]]
        );

        if (!$entity instanceof Detail) {
            throw new NotFoundException(sprintf('Variant by order number %s not found', $number));
        }

        return $entity->getArticle()->getId();
    }

    
Home | Imprint | This part of the site doesn't use cookies.