예제 #1
0
 private function searchBlog(Criteria $criteria, Struct\ProductContextInterface $context)
 {
     /**@var $condition SearchTermCondition*/
     $condition = $criteria->getCondition('search');
     $query = $this->createMultiMatchQuery($condition);
     $search = new Search();
     $search->addQuery($query);
     $search->setFrom(0)->setSize(5);
     $index = $this->indexFactory->createShopIndex($context->getShop());
     $params = ['index' => $index->getName(), 'type' => 'blog', 'body' => $search->toArray()];
     $raw = $this->client->search($params);
     return $this->createBlogStructs($raw);
 }
예제 #2
0
 /**
  * Checks if the provided product is allowed to display in the store front for
  * the provided context.
  *
  * @param Struct\ListProduct $product
  * @param Struct\ProductContextInterface $context
  * @return bool
  */
 private function isProductValid(Struct\ListProduct $product, Struct\ProductContextInterface $context)
 {
     if (in_array($context->getCurrentCustomerGroup()->getId(), $product->getBlockedCustomerGroupIds())) {
         return false;
     }
     $prices = $product->getPrices();
     if (empty($prices)) {
         return false;
     }
     if (!$product->hasAvailableVariant()) {
         return false;
     }
     $ids = array_map(function (Struct\Category $category) {
         return $category->getId();
     }, $product->getCategories());
     return in_array($context->getShop()->getCategory()->getId(), $ids);
 }