コード例 #1
0
 /**
  * Get matching products for variant group
  *
  * @param GroupInterface $variantGroup the variant group
  *
  * @return ProductInterface[]
  */
 protected function getMatchingProductsForVariantGroup(GroupInterface $variantGroup)
 {
     if (!$variantGroup->getId()) {
         return [];
     }
     return $this->repository->findAllForVariantGroup($variantGroup);
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 public function process($group)
 {
     $this->form->setData($group);
     if ($this->request->isMethod('POST')) {
         // TODO : how to fix this ? Load products when ODM storage is used to enable validation
         if (null === $group->getProducts()) {
             $products = $this->productRepository->findAllForGroup($group)->toArray();
             $group->setProducts($products);
         }
         $this->form->submit($this->request);
         if ($this->form->isValid()) {
             $this->onSuccess($group);
             return true;
         } elseif ($group->getType()->isVariant() && $group->getId()) {
             $products = $this->productRepository->findAllForVariantGroup($group);
             $group->setProducts($products);
         }
     }
     return false;
 }