Ejemplo n.º 1
0
 /**
  * {@inheritDoc}
  */
 protected function toEntity(array $product)
 {
     // If the $id isn't set, then the product isn't valid
     if (!isset($product['id'])) {
         return new ProductEntity();
     }
     $imageBag = clone $this->imageManager->getImageBag();
     $imageBag->setId($product['id'])->setCover($product['cover']);
     $entity = new ProductEntity();
     $entity->setImageBag($imageBag)->setId($product['id'], ProductEntity::FILTER_INT)->setLangId($product['lang_id'], ProductEntity::FILTER_INT)->setWebPageId($product['web_page_id'], ProductEntity::FILTER_INT)->setPrice($product['regular_price'], ProductEntity::FILTER_FLOAT)->setStokePrice($product['stoke_price'], ProductEntity::FILTER_FLOAT)->setInStock($product['in_stock'], ProductEntity::FILTER_INT)->setSpecialOffer($product['special_offer'], ProductEntity::FILTER_BOOL)->setDescription($product['description'], ProductEntity::FILTER_SAFE_TAGS)->setPublished($product['published'], ProductEntity::FILTER_BOOL)->setOrder($product['order'], ProductEntity::FILTER_INT)->setSeo($product['seo'], ProductEntity::FILTER_BOOL)->setSlug($this->webPageManager->fetchSlugByWebPageId($product['web_page_id']))->setTitle($product['title'], ProductEntity::FILTER_HTML)->setName($product['name'], ProductEntity::FILTER_HTML)->setKeywords($product['keywords'], ProductEntity::FILTER_HTML)->setMetaDescription($product['meta_description'], ProductEntity::FILTER_HTML)->setCover($product['cover'], ProductEntity::FILTER_TAGS)->setDate($product['date'])->setPermanentUrl('/module/shop/product/' . $entity->getId())->setUrl($this->webPageManager->surround($entity->getSlug(), $entity->getLangId()))->setViewCount($product['views'], ProductEntity::FILTER_INT);
     // It's only set in valid entities
     if (isset($product['categories'])) {
         // Categories
         $entity->setCategoryIds($this->createCategoryIds($product['categories']))->setCategories($this->createCategoryPair($product['categories']));
     }
     return $entity;
 }