Example #1
0
 /**
  * Removes a product by its associated id
  * 
  * @param string $id Product id
  * @return boolean
  */
 private function removeById($id)
 {
     // Remove from a storage first
     $this->productMapper->deleteById($id);
     $this->imageMapper->deleteAllByProductId($id);
     // Now remove from the file-system
     $this->imageManager->delete($id);
     return true;
 }
Example #2
0
 /**
  * Refresh the statistic
  * 
  * @return void
  */
 private function refresh()
 {
     $ids = $this->collection->getKeys();
     foreach ($ids as $id) {
         $valid = $this->productMapper->isPrimaryKeyValue($id);
         if (!$valid) {
             $this->removeById($id);
         }
     }
 }
Example #3
0
 /**
  * Counts amount of products associated with provided category id
  * 
  * @param string $id Category id
  * @return integer
  */
 public function getProductCountByCategoryId($id)
 {
     //@TODO: Add caching layer
     return $this->productMapper->countAllByCategoryId($id);
 }
Example #4
0
 /**
  * Fetches latest product entities
  * 
  * @param integer $limit Limit for fetching
  * @param integer $categoryId Optionally can be filtered by category id
  * @return array
  */
 public function fetchLatestPublished($limit, $categoryId = null)
 {
     return $this->prepareResults($this->productMapper->fetchLatestPublished($limit, $categoryId));
 }