コード例 #1
0
ファイル: CartLogModel.php プロジェクト: Bartex77/redstore
 /**
  * @param integer $productId
  */
 public function addLog($productId)
 {
     $cartLog = new CartLog();
     $cartLog->setSelectionDatetime(new \DateTime());
     $cartLog->setProduct($this->productRepository->find($productId));
     $this->entityManager->persist($cartLog);
     $this->entityManager->flush();
 }
コード例 #2
0
 /**
  * @return array id => name
  */
 public function fetchProductsNamesByIds()
 {
     $output = [];
     $products = $this->productRepository->findAll();
     foreach ($products as $product) {
         $output[$product->getId()] = $product->getName();
     }
     return $output;
 }
コード例 #3
0
ファイル: BasketManager.php プロジェクト: Neirda24/currency
 /**
  * Unserialize the string.
  * Return false if an error occur. Check the symfony logs.
  *
  * @param string $serializedBasket
  *
  * @return Basket|bool
  */
 public function unserializeBasket($serializedBasket)
 {
     $basket = new Basket();
     $data = unserialize($serializedBasket);
     if (true === array_key_exists('products', $data)) {
         $products = $this->productRepository->retrieveByIdList($data['products']);
         $basket->setProducts($products);
     } else {
         //@todo: log error
         return false;
     }
     if (true === array_key_exists('nbPerProduct', $data)) {
         foreach ($data['nbPerProduct'] as $productId => $nb) {
             $basket->setNbProductByProductId($productId, $nb);
         }
     } else {
         //@todo: log error
         return false;
     }
     return $basket;
 }