Guest User

Untitled

a guest
Jan 17th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. <?php
  2.  
  3. namespace SampleModuleBlockAdminhtmlCategoryTree;
  4. use MagentoCatalogModelResourceModelCategoryCollection;
  5. use MagentoFrameworkDataTreeNode;
  6. use MagentoStoreModelStoreManagerInterface;
  7.  
  8.  
  9. /**
  10. * Category container block
  11. */
  12. class Supplier extends MagentoFrameworkViewElementTemplate
  13. {
  14.  
  15. /**
  16. * Category Map collection
  17. *
  18. * @var SampleModuleModelResourceCategoryMapCollectionFactory
  19. */
  20. protected $_categoryMapCollectionFactory;
  21.  
  22. /**
  23. * @var StoreManagerInterface
  24. */
  25. protected $_storeManager;
  26.  
  27. /**
  28. * @param MagentoBackendBlockTemplateContext $context
  29. * @param SampleModuleModelResourceCategoryMapCollectionFactory $categoryMapCollectionFactory
  30. * @param StoreManagerInterface $storeManager
  31. * @param array $data
  32. */
  33. public function __construct(
  34. MagentoBackendBlockTemplateContext $context,
  35. SampleModuleModelResourceCategoryMapCollectionFactory $categoryMapCollectionFactory,
  36. StoreManagerInterface $storeManager,
  37. array $data = []
  38. ) {
  39. $this->_categoryMapCollectionFactory = $categoryMapCollectionFactory;
  40. $this->_storeManager = $storeManager;
  41. parent::__construct($context, $data);
  42. }
  43.  
  44.  
  45. /**
  46. * @param int $categoryId
  47. *
  48. * @return SampleModuleModelResourceCategoryMapCollection
  49. */
  50. protected function getMapsForCategory($categoryId)
  51. {
  52. $categoryMapCollection = $this->_categoryMapCollectionFactory->create();
  53.  
  54. $storeId = $this->_storeManager->getStore()->getId();
  55.  
  56. $categoryMapCollection
  57. ->addFilter('integrastore_category_id', $categoryId)
  58. ->addFilter('shop_id', $storeId)
  59. ->load();
  60.  
  61. return $categoryMapCollection;
  62. }
  63.  
  64. }
  65.  
  66. class CurrentStore
  67. {
  68. public function __construct(
  69. MagentoFrameworkAppRequestHttp $request,
  70. //...
  71. ) {
  72. $websiteId = (int) $request->getParam('website', 0);
  73. // ...
  74. }
  75. }
Add Comment
Please, Sign In to add comment