Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mismatch MRSP constant #88

Open
mirkocesaro opened this issue May 20, 2016 · 3 comments

Comments

3 participants
@mirkocesaro
Copy link

commented May 20, 2016

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).

@victor-v-rad

This comment has been minimized.

Copy link
Collaborator

commented May 20, 2016

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)

@mirkocesaro

This comment has been minimized.

Copy link
Author

commented May 20, 2016

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;
    }

}
@victor-v-rad

This comment has been minimized.

Copy link
Collaborator

commented May 20, 2016

Well done @mirkocesaro !

@ilol ilol closed this Sep 12, 2016

@ilol ilol reopened this Sep 12, 2016

@victor-v-rad victor-v-rad added this to To Do in Community Board Jun 19, 2018

@victor-v-rad victor-v-rad changed the title Mismatch constant Mismatch MRSP constant Jun 19, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.