Magento2 in we have collection of order, product, customer etc. For some bussiness logic we need filter collection with difeerent conditions to get data. In this blog we can see different type of condition for addAttributeToFilter and addFieldToFilter in magento2.We can use addAttributeToFilter and addFieldToFilter we below conditions.Here simple code of load product collection with addAttributeToFilter. Here mention all condition with sample code. Equal Value (eq) Not Equal Value (neq) Like Value (like) From Value…
Magento2, We can see order Information, invoice, Credit Memos, Shipment and Comments History, etc. on the admin order view page. Sometimes this tab may not be enough based on the requirements. Add your custom tab in Admin Order View page with just a simple module.This Blog for Magento version >= 2.4.4 && PHP >= 8.1Before creating the custom tab, we need to create a new module. You can refer a blog on How to create…
When we upgrade magento version then sometimes we faced below error while setup upgrade command run.SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘227569538’ for key ‘catalog_url_rewrite_product_category.PRIMARY’, query was: ALTER TABLE `catalog_url_rewrite_product_category` ADD CONSTRAINT PRIMARY KEY (`url_rewrite_id`), DEFAULT CHARSET=’utf8′, DEFAULT COLLATE=’utf8_general_ci’ We can fix above error by delete all duplicate records:Here is query for delete duplicate records. I hope this blog is useful to solve Duplicate entry for table ‘catalog_url_rewrite_product_category. In case, I missed anything or…
As we know, we need to create a custom module in magento2 to override or impliment new feature in magento.So in this tutorial we will create a custom module. We need to follow simple step to create module. Follow below 4 step for create module.1. Create the module folder at project path app/code/<vendor>/<module_name>2. Create the etc/module.xml file in moduleat app/code/<vendor>/<module_name>/etc/module.xml Above code in MageDad is <vendor> and Module is<module_name>3. Create the registration.php file in moduleat…
For some unique customization, we need to create category attributes to fulfil client requirements. Magento introduce data patch to create attributes after version Magento 2.3. So, We need to create category attribute using data patch in magento2. This Blog for Magento version >= 2.4.4 && PHP >= 8.1Here I created simple category attribute with datatype textCreate file: app/code/MageDad/Module/Setup/Patch/Data/AddCodeCategoryAttribute.php We need to run magento setup upgrade command to run this data patch.php bin/magento setup:upgradeCreate file – app/code/MageDad/Module/view/adminhtml/ui_component/category_form.xml…
When magento2 store has 3rd parties system integration then we might be need to store 3rd parties data in magento to make relationships.We might be need additional attribute to save 3rd parties data in magento 2. Here is post for create new customer attribute in magento2.https://www.magedad.com/magento-2-create-a-customer-attribute-programmatically-using-setup-data-patch/1. Get Custom Customer Attribute Value Programatically 2. Save Custom Customer Attribute Value Programatically That’s it. We also have other customer related post might be it’s help to you. You…
In this blog, We going to to create customer using REST API.First we need to admin token to get customer info.We can refer blog for generate admin tokenhttps://www.magedad.com/magento-2-how-to-generate-admin-token-using-rest-api/ Rest API endpoint = https://domain.test/rest/V1/customersRest API endpoint for store(default is store code) = https://domain.test/rest/default/V1/customers Method = POSTContent type = Content-Type:application/jsonHeader = Authorization: Bearer xxxx_admin_token_xxxx Post Data = Examples:The following image shows a customer create by a REST client: Here is simple php code for call API. This…
For some unique customization, we need to create customer extension attribute to fulfil client requirements in magento2. In this blog, I created extension attribute with different datatype.is_happy_customer booleanhappy_message stringhappy_number inthappy_list arrayhappy_object objectFirst create file etc/extension_attributes.xml Now we need to create interface and model for HappyObjectCreate interface at app/code/MageDad/Module/Api/Data/HappyObjectInterface.php Create model at app/code/MageDad/Module/Model/HappyObject.php Now we create plugin for bind attribute value of extension attribute.Create di.xml at app/code/MageDad/Module/etc/di.xml Create plugin at app/code/MageDad/Module/Plugin/CustomerPlugin.php Above code in line $happy…
In this blog we will get customer data by customer id using REST API.First we need to admin token to get customer info.We can refer blog for generate admin tokenhttps://www.magedad.com/magento-2-how-to-generate-admin-token-using-rest-api/ Rest API endpoint = https://domain.test/rest/V1/customers/:customerIdRest API endpoint for store(default is store code) = https://domain.test/rest/default/V1/customers/:customerId Method = GETContent type = Content-Type:application/jsonHeader = Authorization: Bearer xxxx_admin_token_xxxx Examples:The following image shows a get customer using customer id by a REST client: Here is simple php code for call…
In this blog, we will call rest api for get customer list in magento2.First we need to generate admin token to get customer.You can refer blog for generate admin tokenhttps://www.magedad.com/magento-2-how-to-generate-admin-token-using-rest-api/ Rest API endpoint = https://domain.test/rest/V1/customers/searchMethod = GETContent type = Content-Type:application/jsonHeader = Authorization: Bearer xxxx_token_xxxxParams =searchCriteria[sortOrders][0][field]=entity_idsearchCriteria[sortOrders][0][direction]=ascExample:The following image shows a get customer list using a REST client. I hope this blog is useful to get customer list using Rest API. In case, I missed anything or…