Exemple #1
0
 /**
  * Configure breadcrumbs for view
  * 
  * @param \Shop\Service\ProductEntity $product
  * @return void
  */
 private function configureBreadcrumbs(ProductEntity $product)
 {
     $keeper = $this->getCategoryIdKeeper();
     if ($keeper->hasLastCategoryId()) {
         // Set the last persisted category id
         $product->setCategoryId($keeper->getLastCategoryId(), ProductEntity::FILTER_INT);
         // Append breadcrumbs
         $this->view->getBreadcrumbBag()->add($this->getModuleService('productManager')->getBreadcrumbs($product));
     } else {
         // No last id? Then make sure no breadcrumbs displayed
         $this->view->getBreadcrumbBag()->clear();
     }
 }
Exemple #2
0
 /**
  * Fetches basic product info by its associated id
  * 
  * @param string $id Product id
  * @return \Shop\Service\ProductEntity|boolean
  */
 public function fetchBasicById($id)
 {
     $product = $this->productMapper->fetchBasicById($id);
     // If not empty, then valid $id supplied
     if (!empty($product)) {
         $imageBag = clone $this->imageManager->getImageBag();
         $imageBag->setId($id)->setCover($product['cover']);
         $entity = new ProductEntity();
         $entity->setId($id)->setImageBag($imageBag)->setCover($product['cover'], ProductEntity::FILTER_TAGS)->setName($product['name'], ProductEntity::FILTER_TAGS)->setInStock($product['in_stock'], ProductEntity::FILTER_INT)->setRegularPrice($product['regular_price'], ProductEntity::FILTER_FLOAT)->setStokePrice($product['stoke_price'], ProductEntity::FILTER_FLOAT);
         return $entity;
     } else {
         return false;
     }
 }