0

I've migrated M1 to M2.1.8 by using "UB Data Migration tool", but when I tried to update tier price for a product having "Default Migrated" attribute set it doesn't updated(not getting any error just getting product saved message), others things are updating properly e.g-product name, special price, cost etc.

While for the attribute set "Default" everything working fine.

2
  • My suggestion to use Magento own Data Migration tool and also don't use 2.1.8. Lastest Magento 2 version 2.2.4
    – Amit Bera
    Commented May 24, 2018 at 7:51
  • I've already migrated & made lots of changes,lots of products,orders etc here so for now i can't do this. Commented May 24, 2018 at 8:40

2 Answers 2

0

After lots of debugging, finally, I fixed it via event-observer.

So just created a separated custom module & used "catalog_product_save_before" event.

FilePath:- Namespace/Module/Observer/Tierpriceupdate.php

Here is the observer code:-

  public function execute(\Magento\Framework\Event\Observer $observer)
  {  
    $_product = $observer->getProduct();
    //Get Migrated attribute set id
    $att_set_id=$_product->getAttributeSetId() ;

    // Only fot "Default Migrated" attribute set
    if($att_set_id==11){

    $product_id=$_product->getId() ;     

     // Sql Connection :- 
    $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); // Instance of object manager
    $resource = $objectManager->get('Magento\Framework\App\ResourceConnection');
    $connection = $resource->getConnection();


     $tier_prices=$_product->getData('tier_price') ;

     // echo "<pre>" ; print_r($tier_prices) ; exit;

     foreach($tier_prices as $tier_price){

                $price_qty  = $tier_price['price_qty'];
                $price  = $tier_price['price'];
                $website_id  = $tier_price['website_id'];
          $all_groups=0;
            // When Customer Group As All group 
        if($tier_price['cust_group']==32000){
                  $tier_price['cust_group']=0;
                  $all_groups=1;
          }

          $cust_group  =$tier_price['cust_group'];


        if(isset($tier_price['price_id']) && !empty($tier_price['price_id'])){
            $price_id  =$tier_price['price_id'];
                    if(empty($tier_price['delete']) && !isset($tier_price['delete'])){
                        // Update table catalog_product_entity_tier_price

                        $update_table = "UPDATE `catalog_product_entity_tier_price` SET `all_groups`='$all_groups', `customer_group_id`='$cust_group', `qty`='$price_qty', `value`='$price', `website_id`='$website_id' WHERE  `value_id`='$price_id'" ;
                        // echo $update_table ; exit;

                            $connection->query($update_table);


                    } else{
                        // Delete table row catalog_product_entity_tier_price
                        $delete_table="DELETE FROM `catalog_product_entity_tier_price` WHERE `value_id` = '$price_id'" ;
                        // echo $delete_table ; exit;

                        $connection->query($delete_table);


                    }
        } else{
            // Insert INto catalog_product_entity_tier_price
            $insert_table="INSERT INTO `catalog_product_entity_tier_price` (`entity_id`, `all_groups`, `customer_group_id`, `qty`, `value`, `website_id`) VALUES ('$product_id', '$all_groups', '$cust_group', '$price_qty', '$price', '$website_id')";

            $connection->query($insert_table);
        }

     }

  }
}
0

We wonder if you're using our old script on Github or our latest UB Data Migration Pro package? We no longer maintain the Github version as its codebase was outdated.

If you use our Pro version, you can submit a ticket via our helpdesk, we will work closely with you then.

PS. From your initial question, there's a high chance that it relates to the special case of your data only, not the issue of the migration tool. We will get back to you in more details, if you can provide further info via our helpdesk.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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