How to Create a Setup Script in Magento 2?

InstallSchema – this class will run when the module is installed to set up the database structure.

In this article, we will use the sample module MageChallenge_SetupData to create a demo table.

if you are not ready creating new module follow this link

Create a New Module Magento2

Create a new file app/code/MageChallenge/SetupData/Setup/InstallSchema.php

Continue reading “How to Create a Setup Script in Magento 2?”

Remove Column from Magento2 grid

To remove a column from the magento2 grid we can set “componentDisabled” to True.

Okay, Let’s check with example. For example, I’m going to remove the following column from the magento2 order grid. you can apply whatever UI component grid if you want.

So let say we want to remove Purchase Point and Grand Total (Purchased)

Continue reading “Remove Column from Magento2 grid”

Change Column component of the Magento2 order grid

Changing the UI component based grid Column is very easy in magento2. Today I,m going to change magento2 order grid columns.

As an example let say we have to change the grid column ID to Order #. So you can do like following.

app/code/MageChallenge/OrderGrid/view/adminhtml/ui_component/sales_order_grid.xml

Continue reading “Change Column component of the Magento2 order grid”

Magento2 add product Tier Price programmatically

So If you have a task to add Magento2 tier price when saving product. you can use event “controller_action_catalog_product_save_entity_after”

app/code/MageChallenge/GroupPrice/etc/adminhtml/events.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <event name="controller_action_catalog_product_save_entity_after">
        <observer name="group_price" instance="MageChallenge\GroupPrice\Observer\ProductGroupPrice" />
    </event>
</config>

Continue reading “Magento2 add product Tier Price programmatically”