How to get all categories in configuration (system.xml). magento 2Exclude a specific categoryfunction to display menu from a set levelUnit Test for overwrite collection class in magento2How to add filtering to custom table field column in Customers admin grid in Magento2?main.CRITICAL: Plugin class doesn't existWhy Getting categories and names on product view page Magento 2 fails?Magento 2.1 Create a filter in the product grid by new attributeMagento offline custom Payment method with drop down listTwo categories are loading every available product in categoryHow to solve Front controller reached 100 router match iterations in magento2
Why do distances seem to matter in the Foundation world?
How to not starve gigantic beasts
How did Captain America manage to do this?
Contradiction proof for inequality of P and NP?
Why is the underscore command _ useful?
How exactly does Hawking radiation decrease the mass of black holes?
What was Apollo 13's "Little Jolt" after MECO?
How to copy a file or multiple to the directory I previously was?
Don’t seats that recline flat defeat the purpose of having seatbelts?
What is the term for a person whose job is to place products on shelves in stores?
What is the optimal strategy for the Dictionary Game?
Why does Mind Blank stop the Feeblemind spell?
A Paper Record is What I Hamper
Figure is not placed perfectly
Check if a string is entirely made of the same substring
Creating a chemical industry from a medieval tech level without petroleum
diskutil list shows 20 disk partitions, I only know 3, what are the rest?
Is there a grandfather paradox in Endgame?
Is Diceware more secure than a long passphrase?
How to pronounce 'c++' in Spanish
As an international instructor, should I openly talk about my accent?
What makes accurate emulation of old systems a difficult task?
If a planet has 3 moons, is it possible to have triple Full/New Moons at once?
My bank got bought out, am I now going to have to start filing tax returns in a different state?
How to get all categories in configuration (system.xml). magento 2
Exclude a specific categoryfunction to display menu from a set levelUnit Test for overwrite collection class in magento2How to add filtering to custom table field column in Customers admin grid in Magento2?main.CRITICAL: Plugin class doesn't existWhy Getting categories and names on product view page Magento 2 fails?Magento 2.1 Create a filter in the product grid by new attributeMagento offline custom Payment method with drop down listTwo categories are loading every available product in categoryHow to solve Front controller reached 100 router match iterations in magento2
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I'm getting all the categories in system.xml using
<?php
namespace VenderModuleModelConfigSource;
use MagentoFrameworkOptionArrayInterface;
class Category implements ArrayInterfaceint $pageSize
* @return MagentoCatalogModelResourceModelCategoryCollection or array
*/
public function getCategoryCollection($isActive = true, $level = false, $sortBy = false, $pageSize = false)
$collection = $this->_categoryCollectionFactory->create();
$collection->addAttributeToSelect('*');
// select only active categories
if ($isActive)
$collection->addIsActiveFilter();
// select categories of certain level
if ($level)
$collection->addLevelFilter($level);
// sort categories by some value
if ($sortBy)
$collection->addOrderField($sortBy);
// select certain number of categories
if ($pageSize)
$collection->setPageSize($pageSize);
return $collection;
public function toOptionArray()
$arr = $this->_toArray();
$ret = [];
foreach ($arr as $key => $value)
$ret[] = [
'value' => $key,
'label' => $value
];
return $ret;
private function _toArray()
$categories = $this->getCategoryCollection(true, false, false, false);
$catagoryList = array();
foreach ($categories as $category)
$catagoryList[$category->getEntityId()] = __($this->_getParentName($category->getPath()) . $category->getName());
return $catagoryList;
private function _getParentName($path = '')
$parentName = '';
$rootCats = array(1,2);
$catTree = explode("/", $path);
array_pop($catTree);
if($catTree && (count($catTree) > count($rootCats)))
foreach ($catTree as $catId)
if(!in_array($catId, $rootCats))
$category = $this->_categoryFactory->create()->load($catId);
$categoryName = $category->getName();
$parentName .= $categoryName . ' -> ';
return $parentName;
but when I submit my extension to magento QA then they give me the error
now how can I solve this? they are saying that I'm duplicating the class the which core class I can use to get all categories like that
magento2 category backend
add a comment |
I'm getting all the categories in system.xml using
<?php
namespace VenderModuleModelConfigSource;
use MagentoFrameworkOptionArrayInterface;
class Category implements ArrayInterfaceint $pageSize
* @return MagentoCatalogModelResourceModelCategoryCollection or array
*/
public function getCategoryCollection($isActive = true, $level = false, $sortBy = false, $pageSize = false)
$collection = $this->_categoryCollectionFactory->create();
$collection->addAttributeToSelect('*');
// select only active categories
if ($isActive)
$collection->addIsActiveFilter();
// select categories of certain level
if ($level)
$collection->addLevelFilter($level);
// sort categories by some value
if ($sortBy)
$collection->addOrderField($sortBy);
// select certain number of categories
if ($pageSize)
$collection->setPageSize($pageSize);
return $collection;
public function toOptionArray()
$arr = $this->_toArray();
$ret = [];
foreach ($arr as $key => $value)
$ret[] = [
'value' => $key,
'label' => $value
];
return $ret;
private function _toArray()
$categories = $this->getCategoryCollection(true, false, false, false);
$catagoryList = array();
foreach ($categories as $category)
$catagoryList[$category->getEntityId()] = __($this->_getParentName($category->getPath()) . $category->getName());
return $catagoryList;
private function _getParentName($path = '')
$parentName = '';
$rootCats = array(1,2);
$catTree = explode("/", $path);
array_pop($catTree);
if($catTree && (count($catTree) > count($rootCats)))
foreach ($catTree as $catId)
if(!in_array($catId, $rootCats))
$category = $this->_categoryFactory->create()->load($catId);
$categoryName = $category->getName();
$parentName .= $categoryName . ' -> ';
return $parentName;
but when I submit my extension to magento QA then they give me the error
now how can I solve this? they are saying that I'm duplicating the class the which core class I can use to get all categories like that
magento2 category backend
add a comment |
I'm getting all the categories in system.xml using
<?php
namespace VenderModuleModelConfigSource;
use MagentoFrameworkOptionArrayInterface;
class Category implements ArrayInterfaceint $pageSize
* @return MagentoCatalogModelResourceModelCategoryCollection or array
*/
public function getCategoryCollection($isActive = true, $level = false, $sortBy = false, $pageSize = false)
$collection = $this->_categoryCollectionFactory->create();
$collection->addAttributeToSelect('*');
// select only active categories
if ($isActive)
$collection->addIsActiveFilter();
// select categories of certain level
if ($level)
$collection->addLevelFilter($level);
// sort categories by some value
if ($sortBy)
$collection->addOrderField($sortBy);
// select certain number of categories
if ($pageSize)
$collection->setPageSize($pageSize);
return $collection;
public function toOptionArray()
$arr = $this->_toArray();
$ret = [];
foreach ($arr as $key => $value)
$ret[] = [
'value' => $key,
'label' => $value
];
return $ret;
private function _toArray()
$categories = $this->getCategoryCollection(true, false, false, false);
$catagoryList = array();
foreach ($categories as $category)
$catagoryList[$category->getEntityId()] = __($this->_getParentName($category->getPath()) . $category->getName());
return $catagoryList;
private function _getParentName($path = '')
$parentName = '';
$rootCats = array(1,2);
$catTree = explode("/", $path);
array_pop($catTree);
if($catTree && (count($catTree) > count($rootCats)))
foreach ($catTree as $catId)
if(!in_array($catId, $rootCats))
$category = $this->_categoryFactory->create()->load($catId);
$categoryName = $category->getName();
$parentName .= $categoryName . ' -> ';
return $parentName;
but when I submit my extension to magento QA then they give me the error
now how can I solve this? they are saying that I'm duplicating the class the which core class I can use to get all categories like that
magento2 category backend
I'm getting all the categories in system.xml using
<?php
namespace VenderModuleModelConfigSource;
use MagentoFrameworkOptionArrayInterface;
class Category implements ArrayInterfaceint $pageSize
* @return MagentoCatalogModelResourceModelCategoryCollection or array
*/
public function getCategoryCollection($isActive = true, $level = false, $sortBy = false, $pageSize = false)
$collection = $this->_categoryCollectionFactory->create();
$collection->addAttributeToSelect('*');
// select only active categories
if ($isActive)
$collection->addIsActiveFilter();
// select categories of certain level
if ($level)
$collection->addLevelFilter($level);
// sort categories by some value
if ($sortBy)
$collection->addOrderField($sortBy);
// select certain number of categories
if ($pageSize)
$collection->setPageSize($pageSize);
return $collection;
public function toOptionArray()
$arr = $this->_toArray();
$ret = [];
foreach ($arr as $key => $value)
$ret[] = [
'value' => $key,
'label' => $value
];
return $ret;
private function _toArray()
$categories = $this->getCategoryCollection(true, false, false, false);
$catagoryList = array();
foreach ($categories as $category)
$catagoryList[$category->getEntityId()] = __($this->_getParentName($category->getPath()) . $category->getName());
return $catagoryList;
private function _getParentName($path = '')
$parentName = '';
$rootCats = array(1,2);
$catTree = explode("/", $path);
array_pop($catTree);
if($catTree && (count($catTree) > count($rootCats)))
foreach ($catTree as $catId)
if(!in_array($catId, $rootCats))
$category = $this->_categoryFactory->create()->load($catId);
$categoryName = $category->getName();
$parentName .= $categoryName . ' -> ';
return $parentName;
but when I submit my extension to magento QA then they give me the error
now how can I solve this? they are saying that I'm duplicating the class the which core class I can use to get all categories like that
magento2 category backend
magento2 category backend
asked 1 hour ago
Asad KhanAsad Khan
39510
39510
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You should try not to use a "core-like" class name. I doubt, it is because you named your class as Category which is already present in the Magento core.
You can change it to something like Catlist at least it doesn't seem to duplicate any existing core class and instead more like what it seems to, which is Category list.
didn't you think that we use many classes with the same name likeData.php(Helper) and many more.. but they didn't give me any error on that class
– Asad Khan
1 hour ago
Yeah, you are right. I got your point. But having read the review results there's no way you can solve it with a plugin. Just my thought
– magefms
1 hour ago
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f272563%2fhow-to-get-all-categories-in-configuration-system-xml-magento-2%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You should try not to use a "core-like" class name. I doubt, it is because you named your class as Category which is already present in the Magento core.
You can change it to something like Catlist at least it doesn't seem to duplicate any existing core class and instead more like what it seems to, which is Category list.
didn't you think that we use many classes with the same name likeData.php(Helper) and many more.. but they didn't give me any error on that class
– Asad Khan
1 hour ago
Yeah, you are right. I got your point. But having read the review results there's no way you can solve it with a plugin. Just my thought
– magefms
1 hour ago
add a comment |
You should try not to use a "core-like" class name. I doubt, it is because you named your class as Category which is already present in the Magento core.
You can change it to something like Catlist at least it doesn't seem to duplicate any existing core class and instead more like what it seems to, which is Category list.
didn't you think that we use many classes with the same name likeData.php(Helper) and many more.. but they didn't give me any error on that class
– Asad Khan
1 hour ago
Yeah, you are right. I got your point. But having read the review results there's no way you can solve it with a plugin. Just my thought
– magefms
1 hour ago
add a comment |
You should try not to use a "core-like" class name. I doubt, it is because you named your class as Category which is already present in the Magento core.
You can change it to something like Catlist at least it doesn't seem to duplicate any existing core class and instead more like what it seems to, which is Category list.
You should try not to use a "core-like" class name. I doubt, it is because you named your class as Category which is already present in the Magento core.
You can change it to something like Catlist at least it doesn't seem to duplicate any existing core class and instead more like what it seems to, which is Category list.
answered 1 hour ago
magefmsmagefms
2,8502529
2,8502529
didn't you think that we use many classes with the same name likeData.php(Helper) and many more.. but they didn't give me any error on that class
– Asad Khan
1 hour ago
Yeah, you are right. I got your point. But having read the review results there's no way you can solve it with a plugin. Just my thought
– magefms
1 hour ago
add a comment |
didn't you think that we use many classes with the same name likeData.php(Helper) and many more.. but they didn't give me any error on that class
– Asad Khan
1 hour ago
Yeah, you are right. I got your point. But having read the review results there's no way you can solve it with a plugin. Just my thought
– magefms
1 hour ago
didn't you think that we use many classes with the same name like
Data.php (Helper) and many more.. but they didn't give me any error on that class– Asad Khan
1 hour ago
didn't you think that we use many classes with the same name like
Data.php (Helper) and many more.. but they didn't give me any error on that class– Asad Khan
1 hour ago
Yeah, you are right. I got your point. But having read the review results there's no way you can solve it with a plugin. Just my thought
– magefms
1 hour ago
Yeah, you are right. I got your point. But having read the review results there's no way you can solve it with a plugin. Just my thought
– magefms
1 hour ago
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f272563%2fhow-to-get-all-categories-in-configuration-system-xml-magento-2%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown