Exemplo n.º 1
0
 /**
  * Handle Stock
  *
  * @param \Extcode\Cart\Domain\Model\Cart\Cart $cart
  */
 public function handleStock(\Extcode\Cart\Domain\Model\Cart\Cart $cart)
 {
     $data = ['cart' => $cart];
     $signalSlotDispatcher = $this->objectManager->get('TYPO3\\CMS\\Extbase\\SignalSlot\\Dispatcher');
     $signalSlotDispatcher->dispatch(__CLASS__, 'beforeHandleStock', [$data]);
     foreach ($cart->getProducts() as $cartProduct) {
         /** @var $cartProduct \Extcode\Cart\Domain\Model\Cart\Product */
         if (!$cartProduct->getContentId()) {
             $productProduct = $this->productProductRepository->findByUid($cartProduct->getProductId());
             if ($productProduct) {
                 $productProduct->removeFromStock($cartProduct->getQuantity());
             }
             $this->productProductRepository->update($productProduct);
         }
     }
     $this->persistenceManager->persistAll();
     $data = ['cart' => $cart];
     $signalSlotDispatcher = $this->objectManager->get('TYPO3\\CMS\\Extbase\\SignalSlot\\Dispatcher');
     $signalSlotDispatcher->dispatch(__CLASS__, 'afterHandleStock', [$data]);
 }
Exemplo n.º 2
0
 /**
  * action teaser
  *
  * @return void
  */
 public function teaserAction()
 {
     $products = $this->productRepository->findByUids($this->settings['productUids']);
     $this->view->assign('products', $products);
 }