Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace HelloBrandBlock;
- class Brandlisting extends MagentoFrameworkViewElementTemplate
- {
- protected $categoryCollectionFactory;
- public function __construct(
- MagentoBackendBlockTemplateContext $context,
- MagentoCatalogModelResourceModelCategoryCollectionFactory $categoryCollectionFactory,
- array $data = []
- )
- {
- $this->categoryCollectionFactory = $categoryCollectionFactory;
- parent::__construct($context, $data);
- }
- public function getDescendants($category, $levels = 2)
- {
- if ((int)$levels < 1) {
- $levels = 1;
- }
- $collection = $this->categoryCollectionFactory->create()
- ->addPathsFilter($category->getPath().'/')
- ->addLevelFilter($category->getLevel() + $levels);
- return $collection;
- }
- }
- {{block class="VendorModuleBlockTest" name="test" template="Vendor_Module::test.phtml"}}
Add Comment
Please, Sign In to add comment