Magento 2: Change Increment ID Prefix, Suffix, Start value, Step, Pad length of Order, Invoice, Creditmemo & Shipment

This article shows how you can change/update the Order Increment ID, Invoice Increment ID, Creditmemo Increment ID, Shipment Increment ID of your Magento 2 store. In Magento 1, you could simply change the increment prefix and last increment id from the database table entity_store_id. In Magento 2, it’s different. You have the option to change … Read more

Magento 2: Create/Alter Database Table & Insert Data while Installing/Upgrading Module

This article shows how you can create a new database table and install data into the table while installing a custom module or upgrading the module in Magento 2. The install and upgrade setup script file should be inside the Setup folder of your module. The install script should be named InstallSchema.php & InstallData.php and … Read more

Magento 2: Create/Add Product from module’s InstallData or UpgradeData Script

This article shows how you can add a product from your custom module’s InstallData or UpgradeData Setup script file. This code is useful when you need to auto add product while installing or upgrading your custom module. Add product from InstallData Setup Script This will add product when you install your custom module for the … Read more

Magento 2: Insert Multiple Rows into Database Table

This article shows how you can insert multiple rows or records into your database table. Generally, we add a single row of data into the database table. However, we have situations where we need to insert multiple rows of data into the table at once. We can do so by running the insert query multiple … Read more

Magento 2: Create/Add Configurable Product Programmatically

This article shows how you can add Configurable Product programmatically in Magento 2. I am using a standalone script for this purpose using Object Manager. You can use this code in your custom module as well by using Dependency Injection (DI) instead of Object Manager. Initialize Object Manager and Set the Area code The following … Read more

Magento 2: Create/Add Product Programmatically [Simple & Virtual Product with Image, Category & Custom Option]

This article shows how you can add Simple & Virtual products programmatically in Magento 2. This article also shows how you can: – add images to the product – assign the product to different categories – add custom options to the product I am using a standalone script for this purpose using Object Manager. You … Read more