-
Notifications
You must be signed in to change notification settings - Fork 9.4k
#274 Admin Global Search: Search categories #28588
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#274 Admin Global Search: Search categories #28588
Conversation
Hi @FredericMartinez. Thank you for your contribution
❗ Automated tests can be triggered manually with an appropriate comment:
You can find more information about the builds here ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review. For more details, please, review the Magento Contributor Guide documentation. |
@magento give me test instance |
Hi @FredericMartinez. Thank you for your request. I'm working on Magento instance for you |
Hi @FredericMartinez, here is your new Magento instance. |
@magento run Unit Tests |
@magento give me test instance |
Hi @Stepa4man. Thank you for your request. I'm working on Magento instance for you |
Hi @FredericMartinez I want to ask you to cover implemented functionality by tests according to DOD Also please add to all changed (created) php files declare(strict_types=1); You can read more here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@FredericMartinez
Please check out my comments.
I know you just implemented it as \Magento\CatalogSearch\Model\Search\Catalog
But it's quite an old class, If you have doubts about how to write code you can read this documentation
{ | ||
$this->_adminhtmlData = $adminhtmlData; | ||
$this->categoryRepository = $categoryRepository; | ||
$this->searchCriteriaBuilder = $searchCriteriaBuilder; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use searchCriteriaBuilderFactory here
$filters[] = $this->filterBuilder | ||
->setField($field) | ||
->setConditionType('like') | ||
->setValue('%' . $this->getQuery() . '%') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use sprintf
here
foreach ($searchResults->getItems() as $category) { | ||
$description = strip_tags($category->getDescription()); | ||
$result[] = [ | ||
'id' => 'category/1/' . $category->getId(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use sprintf here
protected $_adminhtmlData = null; | ||
|
||
/** | ||
* @var \Magento\Catalog\Api\CategoryListInterface | ||
*/ | ||
protected $categoryRepository; | ||
|
||
/** | ||
* @var \Magento\Framework\Api\SearchCriteriaBuilder | ||
*/ | ||
protected $searchCriteriaBuilder; | ||
|
||
/** | ||
* @var \Magento\Framework\Api\FilterBuilder | ||
*/ | ||
protected $filterBuilder; | ||
|
||
/** | ||
* Magento string lib | ||
* | ||
* @var \Magento\Framework\Stdlib\StringUtils | ||
*/ | ||
protected $string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use a private access modifier
* | ||
* @var \Magento\Backend\Helper\Data | ||
*/ | ||
protected $_adminhtmlData = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't user underscore in property name it's an outdated approach
* @param \Magento\Backend\Helper\Data $adminhtmlData | ||
* @param \Magento\Catalog\Api\CategoryListInterface $categoryRepository | ||
* @param \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder | ||
* @param \Magento\Framework\Api\FilterBuilder $filterBuilder | ||
* @param \Magento\Framework\Stdlib\StringUtils $string | ||
*/ | ||
public function __construct( | ||
\Magento\Backend\Helper\Data $adminhtmlData, | ||
\Magento\Catalog\Api\CategoryListInterface $categoryRepository, | ||
\Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder, | ||
\Magento\Framework\Api\FilterBuilder $filterBuilder, | ||
\Magento\Framework\Stdlib\StringUtils $string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please import all classes
protected $string; | ||
|
||
/** | ||
* Initialize dependencies. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if we need comment here.
* @method array getResults() | ||
* @api | ||
*/ | ||
class Category extends \Magento\Framework\DataObject |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please import parent class
Hi @Stepa4man |
@Stepa4man Thanks you for your review. I understand all your comments about style codings You can find almost a copy/paste from this class with a category filter instead of a customer filter. Actually, I hesitated to write the class properly, but I assume to have the same old code style. My point was to contributed as it, it works like the old stylish classes and I can get my git patch from this PR in my projects. Thanks for your time @Stepa4man & @okobchenko |
Hi @FredericMartinez, I understand your point but you should also understand us. |
Working on this . |
Added correction for code. |
Hi @sidolov, thank you for the review. |
@magento run all tests |
✔️ QA Passed Preconditions: Magento 2.4-develop Manual testing scenario:
Before: ✖️ We don't see the specified category in the search list After: ✔️ we see in the autocomplete list our new fresh category, a link is valid and redirects to the edit form |
@magento run all tests |
…es' into global_search_categories
@magento run all tests |
Hi @FredericMartinez, thank you for your contribution! |
Description (*)
Global search in backend can search into products, orders, customers, pages and config sections.
Now we can search categories too.
Fixed Issues (if relevant)
Manual testing scenarios (*)
Contribution checklist (*)