Magento 2: Setup Multiple Stores and Websites

This article shows how you can setup multiple stores and multiple websites in your Magento 2 shop. I have assumed that we are having a separate domain or sub-domain for the stores and websites. After adding the necessary stores and websites in the Magento admin, you then need to add some code in either index.php … Read more

Magento 2: Add / Delete / View Custom Options of Product Programmatically

Custom options on Magento products are designed to make simple products function like a configurable product with different choosing options like color, size, etc. before purchasing the product. In this tutorial, I present the code to create/add, view and delete custom options of a simple product in Magento 2. I am using a standalone script … Read more

Magento 2: Delete Duplicate Product Attributes Options Programmatically

This article shows how you can delete duplicate product attribute options in Magento 2. I am using a standalone script for this purpose. You can use this code in your custom module as well. Initialize Object Manager and Set the Area Code The following things are done in the below code: – Initialize the object … Read more

Magento 2: Invalid Form Key. Please refresh the page. Error on Product Save

Problem: The following error occurred while saving a product from Magento 2 admin: Invalid Form Key. Please refresh the page. Cause: The cause of this error is related to the max_input_vars (Maximum Input Variables) directive in the PHP settings. The max_input_vars directive value is the maximum number of variables that can be used for a … Read more

Magento 1 & 2: Join Collection to get Customer Fullname

This article shows how you can use the join query on any custom collection to get the customer firstname, lastname and contact firstname & lastname to get the customer full name. I will be showing example code for both Magento version 1.x and Magento version 2.x. Magento 1: Join Collection to get Customer Fullname I … Read more

Magento 2: Show Calendar/DatePicker & Date-Range Field in Custom Form

This article shows how you can add a calendar or date-picker field in any custom form in Magento 2. I will be showing three different ways of adding date picker in the template file (.phtml) in Magento 2. 1) using calendar widget 2) using datepicker widget 3) using datetimepicker widget I will also show how … Read more

Magento 2: Get Order Info, Order Item, Payment Info, Billing Address & Shipping Address by Order ID & Increment ID

This article shows how you can get order information by loading the order by order id or order increment id. We will load the order by order id and also with order increment id. Then, we fetch the following information: – Order details – Order Items Information – Payment information of the Order – Billing … Read more