Skip to main content
edited title
Link
Mahi M
  • 2.5k
  • 2
  • 37
  • 84

Magento 2.3 : Insert data into table using DB SchemaDeclarativeSchema

added 20 characters in body
Source Link
Mahi M
  • 2.5k
  • 2
  • 37
  • 84

I have created upgrade data for insert the values for particular table

<?php

namespace XXX\YYY\Setup;

use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\UpgradeDataInterface;

class UpgradeData implements UpgradeDataInterface
{
    /**
     * Upgrades DB for a module
     *
     * @param ModuleDataSetupInterface $setup
     * @param ModuleContextInterface $context
     * @return void
     */
    public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
    {
        $setup->startSetup();

        /**
         * install product link attributes
         */
        $data = [
            [
                'link_type_id' => 'color',
                'product_link_attribute_code' => 'position',
                'data_type' => 'int',
            ]
        ];

        $setup->getConnection()
            ->insertMultiple($setup->getTable('catalog_product_link_attribute'), $data);

        $setup->endSetup();
    }
}

I need to change this script into Magento 2.3 (declarative schema)

how to do that.

Thanks.

I have created upgrade data for insert the values for particular table

<?php

namespace XXX\YYY\Setup;

use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\UpgradeDataInterface;

class UpgradeData implements UpgradeDataInterface
{
    /**
     * Upgrades DB for a module
     *
     * @param ModuleDataSetupInterface $setup
     * @param ModuleContextInterface $context
     * @return void
     */
    public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
    {
        $setup->startSetup();

        /**
         * install product link attributes
         */
        $data = [
            [
                'link_type_id' => 'color',
                'product_link_attribute_code' => 'position',
                'data_type' => 'int',
            ]
        ];

        $setup->getConnection()
            ->insertMultiple($setup->getTable('catalog_product_link_attribute'), $data);

        $setup->endSetup();
    }
}

I need to change this script into Magento 2.3

how to do that.

Thanks.

I have created upgrade data for insert the values for particular table

<?php

namespace XXX\YYY\Setup;

use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\UpgradeDataInterface;

class UpgradeData implements UpgradeDataInterface
{
    /**
     * Upgrades DB for a module
     *
     * @param ModuleDataSetupInterface $setup
     * @param ModuleContextInterface $context
     * @return void
     */
    public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
    {
        $setup->startSetup();

        /**
         * install product link attributes
         */
        $data = [
            [
                'link_type_id' => 'color',
                'product_link_attribute_code' => 'position',
                'data_type' => 'int',
            ]
        ];

        $setup->getConnection()
            ->insertMultiple($setup->getTable('catalog_product_link_attribute'), $data);

        $setup->endSetup();
    }
}

I need to change this script into Magento 2.3 (declarative schema)

how to do that.

Thanks.

deleted 17 characters in body
Source Link
Mahi M
  • 2.5k
  • 2
  • 37
  • 84

I have created upgrade data for insert the values for particular table

<?php

namespace XXX\YYY\Setup;

use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\UpgradeDataInterface;

class UpgradeData implements UpgradeDataInterface
{
    /**
     * Upgrades DB for a module
     *
     * @param ModuleDataSetupInterface $setup
     * @param ModuleContextInterface $context
     * @return void
     */
    public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
    {
        $setup->startSetup();

        /**
         * install product link attributes
         */
        $data = [
            [
                'link_type_id' => 'color',
                'product_link_attribute_code' => 'position',
                'data_type' => 'int',
            ]
        ];

        $setup->getConnection()
            ->insertMultiple($setup->getTable('catalog_product_link_attribute'), $data);

        $setup->endSetup();
    }
}

I need to insert value using db_schema concept inchange this script into Magento 2.3

how to do that.

Thanks.

I have created upgrade data for insert the values for particular table

<?php

namespace XXX\YYY\Setup;

use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\UpgradeDataInterface;

class UpgradeData implements UpgradeDataInterface
{
    /**
     * Upgrades DB for a module
     *
     * @param ModuleDataSetupInterface $setup
     * @param ModuleContextInterface $context
     * @return void
     */
    public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
    {
        $setup->startSetup();

        /**
         * install product link attributes
         */
        $data = [
            [
                'link_type_id' => 'color',
                'product_link_attribute_code' => 'position',
                'data_type' => 'int',
            ]
        ];

        $setup->getConnection()
            ->insertMultiple($setup->getTable('catalog_product_link_attribute'), $data);

        $setup->endSetup();
    }
}

I need to insert value using db_schema concept in Magento 2.3

how to do that.

Thanks.

I have created upgrade data for insert the values for particular table

<?php

namespace XXX\YYY\Setup;

use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\UpgradeDataInterface;

class UpgradeData implements UpgradeDataInterface
{
    /**
     * Upgrades DB for a module
     *
     * @param ModuleDataSetupInterface $setup
     * @param ModuleContextInterface $context
     * @return void
     */
    public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
    {
        $setup->startSetup();

        /**
         * install product link attributes
         */
        $data = [
            [
                'link_type_id' => 'color',
                'product_link_attribute_code' => 'position',
                'data_type' => 'int',
            ]
        ];

        $setup->getConnection()
            ->insertMultiple($setup->getTable('catalog_product_link_attribute'), $data);

        $setup->endSetup();
    }
}

I need to change this script into Magento 2.3

how to do that.

Thanks.

Need to change question title
Source Link
Rohan Hapani
  • 17.5k
  • 9
  • 55
  • 96
Loading
Source Link
Mahi M
  • 2.5k
  • 2
  • 37
  • 84
Loading