getArticles example


        $params = $this->Request()->getParams();

        $feedId = $params['id'] ?? null;
        if (!empty($feedId)) {
            // Edit Product Feed             /** @var ProductFeed $productFeed */
            $productFeed = $this->get('models')->getRepository(ProductFeed::class)->find($feedId);
            // Clear all previous associations             $productFeed->getCategories()->clear();
            $productFeed->getSuppliers()->clear();
            $productFeed->getArticles()->clear();
        } else {
            // New Product Feed             $productFeed = new ProductFeed();
            // To set this value initial             $productFeed->setLastExport('now');
        }

        if (empty($params['shopId'])) {
            $params['shopId'] = null;
        }
        if (empty($params['categoryId'])) {
            
if (empty($categoryId)) {
            $categoryModel = new Category();
            $this->em->persist($categoryModel);

            // Find parent for newly created category             $params['parentId'] = isset($params['parentId']) && is_numeric($params['parentId']) ? (int) $params['parentId'] : 1;
            /** @var Category $parentCategory */
            $parentCategory = $repo->find($params['parentId']);
            $categoryModel->setParent($parentCategory);

            // If Leaf-Category gets child category move all assignments to new child category             if ($parentCategory->getChildren()->count() === 0 && $parentCategory->getArticles()->count() > 0) {
                /** @var Article $product */
                foreach ($parentCategory->getArticles() as $product) {
                    $product->removeCategory($parentCategory);
                    $product->addCategory($categoryModel);
                }
            }
        } else {
            $categoryModel = $repo->find($categoryId);
        }

        // check if a category could be found
$this->orderRepository = $orderRepository;
    }

    /** * @param string $term * * @return array */
    public function search($term)
    {
        return [
            'articles' => $this->getArticles($term),
            'customers' => $this->getCustomers($term),
            'orders' => $this->getOrders($term),
        ];
    }

    /** * @param string $term * * @return array */
    private function getArticles($term)
    {
Home | Imprint | This part of the site doesn't use cookies.