0

i'm created crud plugin for children and parent table. Can anyone suggest how to get the data from parent table.PLease Help me. Many thanks here are may table

<?php

        namespace ThuyNT\Crud\Setup;
        use Magento\Framework\DB\Ddl\Table;
        use Magento\Framework\DB\Adapter\AdapterInterface;
        use Magento\Framework\Setup\InstallSchemaInterface;
        use Magento\Framework\Setup\ModuleContextInterface;
        use Magento\Framework\Setup\SchemaSetupInterface;

        class InstallSchema implements InstallSchemaInterface
        {

            public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)

            {
                $installer = $setup;
                $installer->startSetup();
        //
                $table = $installer->getConnection()
                    ->newTable($installer->getTable('crud_news_post'));
                $table->addColumn(
                    'entity_id',
                    Table::TYPE_INTEGER,
                    null,
                    [
                        'identity' => true,
                        'unsigned' => true,
                        'nullable' => false,
                        'primary' => true
                    ],
                    'Post ID'
                )
                    ->addColumn(
                        'authorpost_id',
                        Table::TYPE_INTEGER,
                        null,
                        [
                            'unsigned' => true,

                        ],
                        'Post Author ID'
                    )
                    ->addColumn(
                        'title',
                        Table::TYPE_TEXT,
                        255,
                        ['nullable' => false,],
                        'Post Title'
                    )
                    ->addColumn(
                        'url_key',
                        Table::TYPE_TEXT,
                        255,
                        [],
                        'Post Url Key'
                    )
                    ->addColumn(
                        'post_content',
                        Table::TYPE_TEXT,
                        '64k',
                        [],
                        'Post Content'
                    )
                    ->addColumn(
                        'type',
                        Table::TYPE_TEXT,
                        '64k',
                        [],
                        'Post Type'
                    )
                    ->addColumn(
                        'is_active',
                        Table::TYPE_INTEGER,
                        null,
                        [
                            'nullable' => false,
                            'default' => '1',
                        ],
                        'Is Author Active'
                    )
                    ->addColumn(
                        'updated_at',
                        Table::TYPE_TIMESTAMP,
                        null,
                        [],
                        'Update at'
                    )
                    ->addColumn(
                        'created_at',
                        Table::TYPE_TIMESTAMP,
                        null,
                        [],
                        'Creation Time'
                    )->addForeignKey(
                        $installer->getFkName('crud_news_post', 'authorpost_id', 'crud_news_author', 'author_id'),
                        'authorpost_id',
                        $installer->getTable('crud_news_author'),
                        'author_id',
                        Table::ACTION_CASCADE)
                    ->setComment('News posts');



                $table = $installer->getConnection()
                    ->newTable($installer->getTable('crud_news_author'));
                $table->addColumn(
                    'author_id',
                    Table::TYPE_INTEGER,
                    null,
                    [
                        'unsigned' => true,
                        "nullable"=>false,
                        'primary' =>true,

                    ],
                    'Author ID'
                )
                    ->addColumn(
                        'author_name',
                        Table::TYPE_TEXT,
                        255,
                        ['nullable' => false],

                        'Author Name'
                    )
         )


                    ->setComment('Author To Link Table');
                $installer->getConnection()->createTable($table);
                $installer->endSetup();
            }
        }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.