Author: Adam Piotrowski (adam@wellcommerce.org)
Inheritance: extends WellCommerce\Bundle\DoctrineBundle\Entity\EntityInterface, extends WellCommerce\Bundle\DoctrineBundle\Behaviours\Enableable\EnableableInterface, extends WellCommerce\Bundle\CoreBundle\Entity\TranslatableInterface, extends WellCommerce\Bundle\CoreBundle\Entity\TimestampableInterface, extends WellCommerce\Bundle\CoreBundle\Entity\BlameableInterface, extends WellCommerce\Bundle\ShopBundle\Entity\ShopCollectionAwareInterface, extends WellCommerce\Bundle\AppBundle\Entity\HierarchyAwareInterface
Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function getCurrentCategoryIdentifier()
 {
     if ($this->hasCurrentCategory()) {
         return $this->currentCategory->getId();
     }
     return null;
 }
 /**
  * Translates the category
  *
  * @param Locale   $locale
  * @param CategoryInterface $category
  * @param string   $name
  */
 protected function translateCategory(Locale $locale, CategoryInterface $category, $name)
 {
     /**
      * @var $translation \WellCommerce\Bundle\CategoryBundle\Entity\CategoryTranslation
      */
     $translation = $category->translate($locale->getCode());
     $slug = $this->getLocaleSlug($locale, $name);
     $translation->setName($name);
     $translation->setSlug($slug);
     $category->mergeNewTranslations();
 }
Ejemplo n.º 3
0
 /**
  * Returns a dataset of products recommended for category
  *
  * @param CategoryInterface $category
  *
  * @return array
  */
 public function getProductRecommendationsForCategory(CategoryInterface $category)
 {
     $conditions = new ConditionsCollection();
     $conditions->add(new Eq('category', $category->getId()));
     return $this->dataset->getResult('datagrid', ['limit' => 3, 'order_by' => 'name', 'order_dir' => 'asc', 'conditions' => $conditions]);
 }
Ejemplo n.º 4
0
 /**
  * {@inheritdoc}
  */
 public function addChild(CategoryInterface $child)
 {
     $this->children[] = $child;
     $child->setParent($this);
 }
Ejemplo n.º 5
0
 /**
  * {@inheritdoc}
  */
 public function indexAction(CategoryInterface $category)
 {
     $this->addBreadCrumbItem(new BreadcrumbItem(['name' => $category->translate()->getName()]));
     $this->manager->getCategoryContext()->setCurrentCategory($category);
     return $this->displayTemplate('index', ['category' => $category]);
 }