data-migration-tool
data-migration-tool copied to clipboard
Mismatch MRSP constant
I have no problem during the migration but using the migrated data I found a problem with the attribute msrp_display_actual_price_type of the product. In the Magento 1 core the option for "Use config" has value 4 (Mage_Catalog_Model_Product_Attribute_Source_Msrp_Type_Price::TYPE_USE_CONFIG) while the same option in Magento 2 has value 0 (\Magento\Msrp\Model\Product\Attribute\Source\Type\Price::TYPE_USE_CONFIG).
Hi @mirkocesaro
Thank you for posting this issue. We have created internal MAGETWO-53202 to resolve this one. But as quick fix you could check your Magento 2 catalog_product_entity_varchar table after migration and change value from 4 to 0 for all products with attribute id 114 (Msrp attribute)
Thank you @victor-v-rad For now I found the same solution but I have applied it adding a new transform tag in my map.xml file.
I attached here the code
map.xml file:
... <transform> <field>catalog_product_entity_varchar.value</field> <handler class="Bitbull\MagentoPatch\Handler\Catalog\Product\Attribute\Type\Price\ConvertMsrpPriceType"/> </transform> ...
and this is my Handler in ConvertMsrpPriceType.php file
namespace Bitbull\MagentoPatch\Handler\Catalog\Product\Attribute\Type\Price;
use Migration\ResourceModel\Record;
use Migration\ResourceModel\Source;
use Migration\ResourceModel\Adapter\Mysql;
class ConvertMsrpPriceType extends \Migration\Handler\AbstractHandler
{
const MAGENTO1_CONST_FOR_MSRP_DISPLAY_ACTUAL_PRICE_TYPE = 4;
/**
* @var int
*/
protected $productAttributeId;
/**
* @var Source
*/
protected $source;
/**
* @param Source $source
*/
public function __construct( Source $source)
{
$this->source = $source;
}
/**
* @param Record $recordToHandle
* @param Record $oppositeRecord
* @return mixed
*/
public function handle(Record $recordToHandle, Record $oppositeRecord)
{
$value = $recordToHandle->getValue($this->field);
$attributeId= $this->getProductAttributeSets();
if( $value == self::MAGENTO1_CONST_FOR_MSRP_DISPLAY_ACTUAL_PRICE_TYPE
&& $recordToHandle->getValue('attribute_id') == $attributeId){
$recordToHandle->setValue($this->field, \Magento\Msrp\Model\Product\Attribute\Source\Type\Price::TYPE_USE_CONFIG);
}
else{
$recordToHandle->setValue($this->field, $oppositeRecord->getValue($this->field));
}
}
protected function getProductAttributeSets()
{
if (empty($this->productAttributeId)) {
/** @var Mysql $adapter */
$adapter = $this->source->getAdapter();
$query = $adapter->getSelect()
->from(
['eav_attr' => $this->source->addDocumentPrefix('eav_attribute')],
['attribute_id']
)->where('eav_attr.attribute_code = ?', 'msrp_display_actual_price_type');
$this->productAttributeId = (int) $query->getAdapter()->fetchOne($query) ;
}
return $this->productAttributeId;
}
}
Well done @mirkocesaro !