cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 1.9.2 Extension migration to Magento 2.1 SQL scripts not working.

Magento 1.9.2 Extension migration to Magento 2.1 SQL scripts not working.

Hi,

 

I have try to migrate my 1.9 magento extension code to 2.1 but SQL data script seems not compatible and giving error while installing the module:

 

Following are the migrated scripts:

<?php
/**
* Solvingmagento AffiliateProduct install script
*
*/


namespace Solvingmagento\AffiliateProduct\Setup;

use Magento\Eav\Setup\EavSetup;
use Magento\Eav\Setup\EavSetupFactory;
use Magento\Framework\Setup\InstallDataInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;


class InstallData implements InstallDataInterface
{
/**
* EAV setup factory
*
* @var EavSetupFactory
*/
protected $eavSetupFactory;

/**
* Init
*
* @param EavSetupFactory $eavSetupFactory
*/
public function __construct(EavSetupFactory $eavSetupFactory)
{
$this->eavSetupFactory = $eavSetupFactory;
}

/**
* {@inheritdoc}
*/
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
/** @var EavSetup $eavSetup */
$eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);

//associate these attributes with new product type
$fieldList = [
'type',
'attribute_group_id'.
'affiliate',
'price',
'special_price',
'special_from_date',
'special_to_date',
'minimal_price',
'cost',
'tier_price',
'weight',
];

// make these attributes applicable to new product type
foreach ($fieldList as $field) {
$applyTo = explode(
',',
$eavSetup->getAttribute(\Magento\Catalog\Model\Product::ENTITY, $field, 'apply_to')
);
if (!in_array(\Solvingmagento\AffiliateProduct\Model\Product\Type::TYPE_AFFILIATE, $applyTo)) {
$applyTo[] = \Solvingmagento\AffiliateProduct\Model\Product\Type::TYPE_AFFILIATE;
$eavSetup->updateAttribute(
\Magento\Catalog\Model\Product::ENTITY,
$field,
'apply_to',
implode(',', $applyTo)
);
}
}
}
}

 

Can some body help here in corrector the scripts?

2 REPLIES 2

Re: Magento 1.9.2 Extension migration to Magento 2.1 SQL scripts not working.

Hi there,

 

We have analyzed you code and need R&D to resolve this issue.

 

Yes, we can help you.

 

We need some details from you. If still you have this issue kindly contact me.

 

Regards

 

Adrian Williams

S k y p e :- cisin.adrian

 

Re: Magento 1.9.2 Extension migration to Magento 2.1 SQL scripts not working.

Many errors can be occured in migrating data from magento 1.9 to 2.x. There are two different versions with different systems. Did you know Magento upgrade guide?