Guest User

Untitled

a guest
May 23rd, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. namespace HelloBrandBlock;
  2.  
  3. class Brandlisting extends MagentoFrameworkViewElementTemplate
  4. {
  5. protected $categoryCollectionFactory;
  6. public function __construct(
  7. MagentoBackendBlockTemplateContext $context,
  8. MagentoCatalogModelResourceModelCategoryCollectionFactory $categoryCollectionFactory,
  9. array $data = []
  10. )
  11. {
  12. $this->categoryCollectionFactory = $categoryCollectionFactory;
  13. parent::__construct($context, $data);
  14. }
  15. public function getDescendants($category, $levels = 2)
  16. {
  17. if ((int)$levels < 1) {
  18. $levels = 1;
  19. }
  20. $collection = $this->categoryCollectionFactory->create()
  21. ->addPathsFilter($category->getPath().'/')
  22. ->addLevelFilter($category->getLevel() + $levels);
  23. return $collection;
  24. }
  25.  
  26. }
  27.  
  28. {{block class="VendorModuleBlockTest" name="test" template="Vendor_Module::test.phtml"}}
Add Comment
Please, Sign In to add comment