الأخبار التكنولوجية والاستعراضات والنصائح!

كيفية إضافة عمود رمز القسيمة في Magento 2 Order Grid

ستساعدك المقالة التالية: كيفية إضافة عمود رمز القسيمة في Magento 2 Order Grid

<؟ php

Vendor \ Module \ Setup مساحة الاسم ؛

استخدم Magento \ Framework \ Setup \ InstallSchemaInterface ؛

استخدام Magento \ Framework \ Setup \ ModuleContextInterface ؛

استخدم Magento \ Framework \ Setup \ SchemaSetupInterface ؛

تطبق فئة InstallSchema InstallSchemaInterface

{

/ **

* {inheritdoc}

*uppressWarnings (PHPMD.ExcessiveMethodLength)

* /

تثبيت الوظيفة العامة (إعداد $ SchemaSetupInterface ، ModuleContextInterface $ Context)

{

المثبت $ = الإعداد $؛

$ installer-> startSetup () ؛

/ * أثناء تثبيت الوحدة النمطية ، يُنشئ عمودًا في جدول sales_order_grid * /

$ eavTable = $ installer-> getTable (‘sales_order_grid’) ؛

أعمدة $ = [

            ‘coupon_code’ => [

                ‘type’ => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,

                ‘nullable’ => true,

                ‘comment’ => ‘Coupon Code’,

            ]و

$ Connection = $ installer-> getConnection () ؛

foreach ($ عمود كـ $ name => تعريف $) {

$ connection-> addColumn ($ eavTable، $ name، $ definition)؛

}

$ installer-> endSetup () ؛

}

}