/** * @param Shop $shop * @param Product $product * @return bool */ private function isValid(Shop $shop, $product) { $valid = in_array($shop->getCategory()->getId(), $product->getCategoryIds()); if (!$valid) { return false; } return true; }
private function filterShopBlog(Shop $shop, $ids) { $query = $this->connection->createQueryBuilder(); $query->select('blog.id')->from('s_blog', 'blog')->innerJoin('blog', 's_categories', 'category', 'category.id = blog.category_id AND category.path LIKE :path')->andWhere('blog.id IN (:ids)')->setParameter(':path', '%|' . (int) $shop->getCategory()->getId() . '|%')->setParameter(':ids', $ids, Connection::PARAM_INT_ARRAY); return $query->execute()->fetchAll(\PDO::FETCH_COLUMN); }
/** * Validates if the product is available in the current shop * @param int $productId * @param Shop $shop */ private function isProductAvailableInShop($productId, $shop) { $query = $this->connection->createQueryBuilder(); $query->select('categories.categoryID')->from('s_articles_categories_ro', 'categories')->where('categories.articleID = :productId')->andWhere('categories.categoryID = :categoryId')->setParameter(':productId', $productId)->setParameter(':categoryId', $shop->getCategory()->getId())->setMaxResults(1); return $query->execute()->fetch(\PDO::FETCH_COLUMN); }
private function getBlogIds(Shop $shop) { $query = $this->connection->createQueryBuilder(); $query->select('blog.id')->from('s_blog', 'blog')->innerJoin('blog', 's_categories', 'category', 'category.id = blog.category_id AND category.path LIKE :path')->setParameter(':path', '%|' . (int) $shop->getCategory()->getId() . '|%'); return $query->execute()->fetchAll(\PDO::FETCH_COLUMN); }