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…
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, I created customer address attribute programmatic in magento 2. Code is supported to php8 and magento 2.4.6 😍Let’s see how to create customer address attribute programmatically. We are creating customer address attribute name unique_id.First, Create data patch class like AddUniqueIdAddressAttribute.php file at path app/code/Vendor/Module/Setup/Patch/Data/AddUniqueIdAddressAttribute.php After create patch run magento setup upgrade command for execute code.php bin/magento setup:upgradeWe can see newly created customer address attribute in customer edit/add. I hope this blog is useful for…
If you faced issue of customer attribute not saving value in admin panel then this blog is for you. This issue happen if new created attribute not assigned to attribute set. Maybe you missed below code in your patch. Here is complete blog for create customer attribute if you still facin issue please refer blog I hope this blog is useful for fix customer attribute not saving issue in magento2. In case, I missed anything…
In this blog, I created customer attribute programmatically in magento 2. Code is supported to php8 and magento 2.4.6 😍Let’s see, how to create customer attribute programmatically. We are creating customer attribute name external_id.First, Create data patch class like AddExternalIdCustomerAttribute.php file at path app/code/Vendor/Module/Setup/Patch/Data/AddExternalIdCustomerAttribute.php After create patch run magento setup upgrade command to create customer attribute.php bin/magento setup:upgradeWe can see newly created customer attribute in customer edit/add. I hope this blog is useful for create customer…
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…