HOW TO CREATE A TAB IN Admin CUSTOMER EDIT PAGE IN MAGENTO 2?

In Magento 2, You can add a new custom tab on the Customer Edit page.

If you want to add a new tab in the Customer edit section for your custom requirement, You can add easily a customer tab in the Customer edit section.

You need to create a simple module to add an extra tab in the customer edit section.

Refer to the code snippet for adding an extra tab,
I have taken Rbj as Packagename and CustomerTab as modulename for simplicity. Continue reading “HOW TO CREATE A TAB IN Admin CUSTOMER EDIT PAGE IN MAGENTO 2?”

How to apply OR conditions to searchCriteria filter Magento 2?

Third Party Platform interact with Magento 2 by API. When you are working for API related stuff and using SearchCriteriaBuilder Object for your query and if you want to apply OR conditions for custom query, You need to define setFilterGroups([Object]) for OR query.

Whenever you are dealing with SearchCriteriaBuilder in Magento 2, You might be need to query with OR conditions for custom requirement, You can give OR conditions to Magento\Framework\Api\SearchCriteriaBuilder by simple code snippets.

Let’s imagine, We built a query using OR conditions for Products. Continue reading “How to apply OR conditions to searchCriteria filter Magento 2?”

How to apply OR conditions to collection in Magento 2?

In Magento 2, You can apply OR conditions on collection. By default, When you work with collection, Your conditions will be AND.

AND Condition
Fetch collection of only those products whose sku is like `24MB%` AND `type_id` is equal to simple.

$collection = $this->productCollectionFactory->create();
$collection->addAttributeToFilter('sku', array('like' => '24MB%'));
$collection->addAttributeToFilter('type_id', array('eq' => 'simple'));

Output:
SELECT `e`.* FROM `catalog_product_entity` AS `e` WHERE (`e`.`sku` LIKE ’24MB%’) AND (`e`.`type_id` = ‘simple’); Continue reading “How to apply OR conditions to collection in Magento 2?”