/** * Class constructor. */ public function __construct() { $this->category = Shopware()->Shop()->getCategory(); $this->categoryId = $this->category->getId(); $this->translationId = !Shopware()->Shop()->getDefault() ? Shopware()->Shop()->getId() : null; $this->customerGroupId = (int) Shopware()->Modules()->System()->sSYSTEM->sUSERGROUPDATA['id']; }
public function __construct(\Shopware\Models\Category\Category $category = null, $translationId = null, $customerGroupId = null) { $container = Shopware()->Container(); $this->category = $category ?: Shopware()->Shop()->getCategory(); $this->categoryId = $this->category->getId(); $this->translationId = $translationId ?: (!Shopware()->Shop()->getDefault() ? Shopware()->Shop()->getId() : null); $this->customerGroupId = $customerGroupId ?: (int) Shopware()->Modules()->System()->sUSERGROUPDATA['id']; $this->config = $container->get('config'); $this->db = $container->get('db'); $this->eventManager = $container->get('events'); $this->contextService = $container->get('shopware_storefront.context_service'); $this->listProductService = $container->get('shopware_storefront.list_product_service'); $this->productService = $container->get('shopware_storefront.product_service'); $this->productNumberSearch = $container->get('shopware_search.product_number_search'); $this->configuratorService = $container->get('shopware_storefront.configurator_service'); $this->propertyService = $container->get('shopware_storefront.property_service'); $this->additionalTextService = $container->get('shopware_storefront.additional_text_service'); $this->searchService = $container->get('shopware_search.product_search'); $this->queryAliasMapper = $container->get('query_alias_mapper'); $this->frontController = $container->get('front'); $this->legacyStructConverter = $container->get('legacy_struct_converter'); $this->legacyEventManager = $container->get('legacy_event_manager'); $this->session = $container->get('session'); $this->storeFrontCriteriaFactory = $container->get('shopware_search.store_front_criteria_factory'); $this->productNumberService = $container->get('shopware_storefront.product_number_service'); $this->articleComparisons = new sArticlesComparisons($this, $container); }
/** * Class constructor. */ public function __construct(\Shopware\Models\Category\Category $category = null, $translationId = null, $customerGroupId = null) { $this->category = $category ?: Shopware()->Shop()->getCategory(); $this->categoryId = $this->category->getId(); $this->translationId = $translationId ?: (!Shopware()->Shop()->getDefault() ? Shopware()->Shop()->getId() : null); $this->customerGroupId = $customerGroupId ?: (int) Shopware()->Modules()->System()->sUSERGROUPDATA['id']; }
public function convertCategory(Models\Category\Category $category) { $struct = new Struct\Category(); $struct->setId($category->getId()); $struct->setName($category->getName()); $struct->setPath($category->getPath()); return $struct; }
/** * @param CategoryEntity $category * @return Category */ public static function createFromCategoryEntity(CategoryEntity $category) { $struct = new self(); $struct->setId($category->getId()); $struct->setName($category->getName()); $struct->setPosition($category->getPosition()); $struct->setParentId($category->getParentId()); $path = $category->getPath(); if ($path) { $path = ltrim($path, '|'); $path = rtrim($path, '|'); $path = explode('|', $path); $struct->setPath(array_reverse($path)); } return $struct; }
/** * @param Category $category */ protected function addPendingMove(Category $category) { $this->pendingMoves[$category->getId()] = array('category' => $category); }
/** * Helper function for the isChildOf function. This function is used for a recursive call. * * @param $category Category * @param $searched Category * @return bool */ protected function isChildOfInternal(Category $category, Category $searched) { if ($category->getParent() && $category->getParent()->getId() === $searched->getId()) { return true; } if ($category->getParent() instanceof Category) { return $this->isChildOfInternal($category->getParent(), $searched); } return false; }
/** * {@inheritDoc} */ public function getId() { if ($this->__isInitialized__ === false) { return (int) parent::getId(); } $this->__initializer__ && $this->__initializer__->__invoke($this, 'getId', array()); return parent::getId(); }
/** * Collects recursively category ids * * @param \Shopware\Models\Category\Category $categoryModel */ protected function collectCategoryIds($categoryModel) { $categoryId = $categoryModel->getId(); $this->setCategoryIdCollection($categoryId); $categories = $categoryModel->getChildren(); if (!$categories) { return; } foreach ($categories as $category) { $this->collectCategoryIds($category); } return; }
/** * @param $number * @param ProductContext $context * @param Category $category * @return array */ protected function getProduct($number, ProductContext $context, Category $category = null) { $product = $this->helper->getSimpleProduct($number, array_shift($context->getTaxRules()), $context->getCurrentCustomerGroup()); $product['categories'] = [['id' => $context->getShop()->getCategory()->getId()]]; if ($category) { $product['categories'] = array(array('id' => $category->getId())); } return $product; }
/** * Check current category for child categories and * add ids to collection. * * @param Category $categoryModel */ private function collectCategoryIds($categoryModel) { $categoryId = $categoryModel->getId(); $this->setCategoryIdCollection($categoryId); $sql = "SELECT id FROM s_categories WHERE path LIKE ?"; $categories = Shopware()->Db()->fetchAll($sql, ['%|' . $categoryId . '|%']); if (!$categories) { return; } foreach ($categories as $categoryId) { $this->setCategoryIdCollection($categoryId); } return; }