Пример #1
0
 /**
  * Collects all price influencer from (in the mentioned order):
  * - article
  * - attribute
  * - attribute value
  *
  * @param \Abra\Cadabra\Domain\Model\Article $article
  * @return \SplObjectStorage
  */
 public static function collectPriceInfluencerFromArticle($article)
 {
     $priceInfluencer = new \SplObjectStorage();
     foreach ($article->getPriceInfluencer() as $articlePriceInfluencer) {
         $priceInfluencer->attach($articlePriceInfluencer);
     }
     /** @var \Abra\Cadabra\Domain\Model\ArticleFeature $feature */
     foreach ($article->getFeatures() as $feature) {
         foreach ($feature->getAttribute()->getPriceInfluencer() as $attributePriceInfluencer) {
             $priceInfluencer->attach($attributePriceInfluencer);
         }
         foreach ($feature->getAttributeValue()->getPriceInfluencer() as $attributeFeaturePriceInfluencer) {
             $priceInfluencer->attach($attributeFeaturePriceInfluencer);
         }
     }
     return $priceInfluencer;
 }
Пример #2
0
 /**
  * @param \Abra\Cadabra\Domain\Model\Article $article
  * @param integer $amount
  *
  * @return void
  */
 public function addArticleAction($article, $amount = 1)
 {
     $positions = $this->basket->getPositions();
     /** @var \Abra\Cadabra\Domain\Model\Ordering\BasketEntry $position */
     foreach ($positions as $position) {
         if ($position->getUid() === $article->getUid()) {
         }
     }
     $basketEntry = new \Abra\Cadabra\Domain\Model\Ordering\BasketEntry();
     $basketEntry->setArticle($article);
     $basketEntry->setAmount($amount);
     $basketEntry->setBasket($this->basket);
     $this->basket->addPosition($basketEntry);
     $this->basketRepository->update($this->basket);
     $this->persistenceManager->persistAll();
     $pageId = $this->settings['basket']['basketPageId'] ? $this->settings['basket']['basketPageId'] : null;
     $this->redirect('show', 'Basket', 'cadabra', null, $pageId);
 }