0

Could anyone please help me how to know the table name from InstallData.php file in this question. there is no InstallSchema.php file

  • I don't understand what exactly your requirement.? Do you want to which table name? – Amit Bera Sep 10 '18 at 12:42
  • It might be customer_eav_attribute – Cold Fridge Sep 10 '18 at 12:45
1

For a flat table structure, the answer from Jaimin is clear enough.

Looking at the answer posted in the question (https://magento.stackexchange.com/a/184009/70848) you referenced, I understand that you want to know the table name, where the custom_field for the customer will go into the database.

First, Magento follows EAV (Entity Attribute Value) structure for product categories, products, customers, customer address, order, invoice, credit memo and shipment entities.

That means, based on the data type of the field, it saves the value of the field related to that particular datatype.

For each entity type, Magento has 5 EAV tables. For example, for customer:

  • customer_entity_datetime
  • customer_entity_decimal
  • customer_entity_int
  • customer_entity_text
  • customer_entity_varchar

Whenever a new attribute is created for any of the entities, it goes to the eav_attribute table, where it saves the attribute code, label, entity type with the related data type.

The value of such attribute is saved, Magento checks the data type of the attribute and based on that it adds a new row in one of the above-related tables.

I hope I was clear enough to explain the basic concept.

Please let me know if there is anything unclear.

0

I have attached sample code of install schema

<?php
/**
 * Copyright © 2015 Bliss. All rights reserved.
 */

namespace Mageplaza\HelloWorld\Setup;

use Magento\Framework\Setup\InstallSchemaInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\SchemaSetupInterface;

/**
 * @codeCoverageIgnore
 */
class InstallSchema implements InstallSchemaInterface
{
    /**
     * {@inheritdoc}
     */
    public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
    {

        $installer = $setup;

        $installer->startSetup();

        /**
         * Create table 'crud_custom'
         */
        $table = $installer->getConnection()->newTable(
            $installer->getTable('mageplaza_helloworld_post')
        )


        $installer->getConnection()->createTable($table);
        /*{{CedAddTable}}*/

        $installer->endSetup();

    }
}

In above you can find code like

$table = $installer->getConnection()->newTable(
    $installer->getTable('mageplaza_helloworld_post')
)

In this code mageplaza_helloworld_post is the name of table.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.