1

I've read various posts here but none of them have been helpful.

Steps I have taken:

  • Remove My_Module from setup_module in DB
  • Add Setup/InstallSchema.php
  • Clear generated/* directory
  • Clear cache
  • Execute magento setup:upgrade
  • I've also tried throwing an exception within the install method. No exception is ever thrown.
<?php

namespace My\Module\AttributeMapper\Setup;

use Magento\Framework\Setup\InstallSchemaInterface;
use Magento\Framework\Setup\SchemaSetupInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use My\Module\AttributeMapper\Helper\Product\AttributeData;

/**
 * Upgrade the Catalog module DB scheme
 */
class InstallSchema implements InstallSchemaInterface
{
    /**
     * {@inheritdoc}
     * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
     * @SuppressWarnings(PHPMD.CyclomaticComplexity)
     * @SuppressWarnings(PHPMD.NPathComplexity)
     */
    public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
    {
        $setup->startSetup();

        $this->addCatalogEav($setup);

        $setup->endSetup();
    }

    /**
     * @param SchemaSetupInterface $installer
     * @return void
     */
    private function addCatalogEav(SchemaSetupInterface $installer)
    {
        $catalogEavTable = $installer->getTable('catalog_eav_attribute');
        $installer->getConnection()->addColumn(
            $catalogEavTable,
            AttributeData::PRODUCT_ATTRIBUTE_OPTION_API_ATTRIBUTE_ID,
            [
                'type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
                'comment' => 'API Attribute GUID Mapping for Product Attribute'
            ]
        );
    }
}

  • Not an actual answer but which version of M2 are you using? If you're using M2.3+ then Schema install scripts are deprecated and you should likely be doing it via the newer Declarative Schema XML devdocs.magento.com/guides/v2.3/extension-dev-guide/… – Rhys - SproutDesk Aug 13 '19 at 23:27
  • check the log files – Mohit Rane Aug 14 '19 at 5:49
  • @MohitRane - nothing is logged when this is executed :/. – TylersSN Aug 14 '19 at 13:21
  • @rhys-sproutdesk I am on 2.2 – TylersSN Aug 14 '19 at 13:21
  • try to add addCatalogEav() code to install() – Mohit Rane Aug 19 '19 at 4:21
0

You can try with the following schema

<?php
namespace My\Module\AttributeMapper\Setup;

use Magento\Framework\Setup\InstallSchemaInterface;
use Magento\Framework\Setup\SchemaSetupInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use My\Module\AttributeMapper\Helper\Product\AttributeData;

/**
 * Upgrade the Catalog module DB scheme
 */
class InstallSchema implements InstallSchemaInterface
{
    /**
     * {@inheritdoc}
     * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
     * @SuppressWarnings(PHPMD.CyclomaticComplexity)
     * @SuppressWarnings(PHPMD.NPathComplexity)
     */
    public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
    {
        $setup->startSetup();
        $connection = $setup->getConnection();
        $connection->addColumn(
            $setup->getTable('catalog_eav_attribute'),
            'name of column',
            [
                'type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
                'length' => 255,
                'nullable' => true,
                'default' => '',
                'comment' => 'Column Name'
            ]
        );  

    $setup->endSetup();
    }
}

I hope it will help you.

| improve this answer | |

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.