src/AppBundle/EventListener/PriceEventListener.php line 498

Open in your IDE?
  1. <?php
  2. namespace AppBundle\EventListener;
  3.   
  4. use Pimcore\Event\Model\ElementEventInterface;
  5. use Pimcore\Event\Model\DataObjectEvent;
  6. use \Pimcore\Model\DataObject;
  7. use \Pimcore\Model\DataObject\PriceEvent;
  8. use \Pimcore\Model\DataObject\ItemMaster;
  9. use Pimcore\Db;
  10. use Pimcore\Log\ApplicationLogger;
  11. use Carbon\Carbon;
  12. class PriceEventListener {
  13.      
  14.     public function onPostUpdate (ElementEventInterface $e
  15.     {
  16.        
  17.         if($e instanceof AssetEvent
  18.         {
  19.             $foo $e->getAsset(); 
  20.         }
  21.          else if ($e instanceof DocumentEvent)
  22.         {
  23.             $foo $e->getDocument(); 
  24.         } 
  25.         else if ($e instanceof DataObjectEvent
  26.         {
  27.              // do something with the object
  28.              $foo $e->getObject();          
  29.              $pid =  $foo->getId(); 
  30.              $p_id=1;      
  31.              $claname '';
  32.              $otype $foo->geto_type();
  33.              $o_parentId$foo->getParentId();
  34.              $user = \Pimcore\Tool\Admin::getCurrentUser();
  35.                 //$foo.reload();
  36.             if($otype == 'object')
  37.             {
  38.                 $claname $foo->geto_className(); 
  39.                 $o_published =$foo->geto_published();       
  40.             }                         
  41.             if(($claname == 'priceEvent' || $claname == 'PriceEvent' ) && $o_published == && $user != null)
  42.             {
  43.                  $Status $foo->getStatus();
  44.                // throw new \Pimcore\Model\Element\ValidationException($Status, 1234); 
  45.                 if($Status == 'Approved')
  46.                 {
  47.                     //throw new \Pimcore\Model\Element\ValidationException("You can not update this object.", 1234); 
  48.                 }
  49.                 $getDateSetter = new \Pimcore\Model\DataObject\DaysSetter\Listing();
  50.                 $getDateSetter->setCondition("brand= :brand", ["brand" => 'all']); 
  51.                 $getDateSetter->load();
  52.                 foreach ($getDateSetter as $itemc
  53.                 {
  54.                     $days=$itemc->getdays(); 
  55.                 }
  56.                     $time "+".$days." days";
  57.                     $masterSkuDetails=$foo->getitemMasterSKU();
  58.                     $changeValue=$foo->getchangeByValue();
  59.                     $statusForValue=$foo->getchangeByPercentValue();
  60.                     $getStartDate=$foo->getstartDate();
  61.                     $getEndDate=$foo->getendDate();
  62.                     $todayDate date('Y-m-d');
  63.                     $afterThreeDay Date('Y-m-d'strtotime($time));
  64.                     if (($getStartDate >= $todayDate) && ($getStartDate <= $afterThreeDay))
  65.                     {
  66.                         throw new \Pimcore\Model\Element\ValidationException("Please select right start date"1234);
  67.                     }
  68.                     else if($getStartDate <= $todayDate)
  69.                     {
  70.                          throw new \Pimcore\Model\Element\ValidationException("Please select right start date"1234);
  71.                     }
  72.         
  73.                     if($getEndDate != NULL)
  74.                     {
  75.                         if ($getEndDate <= $getStartDate)
  76.                         {
  77.                             throw new \Pimcore\Model\Element\ValidationException("Please select right end date "1234);
  78.                         }
  79.                     }   
  80.                     if($statusForValue == "changeByPercentValue")
  81.                     {
  82.                         if(($changeValue 999.99) && ($changeValue < -999.99))            
  83.                         {
  84.                             throw new \Pimcore\Model\Element\ValidationException("Percent should not be less then 999.99 and greter then -999.99"1234);
  85.                         }
  86.                     }
  87.                     if($statusForValue == "changeByPrice")
  88.                     {
  89.                         if($changeValue 0)
  90.                         {
  91.                             throw new \Pimcore\Model\Element\ValidationException("Price should not be less then 0"1234);         
  92.                         }
  93.                     }
  94.                     $getDes=$foo->geteventDesc();
  95.                     $statusApp=$foo->getStatus();
  96.                     $itemMasterSku count($masterSkuDetails);
  97.                     $eventDesc$foo->geteventDesc();
  98.                     $startDate $foo->getstartDate();
  99.                     $endDate $foo->getendDate();
  100.                     $eventSeason $foo->geteventSeason();
  101.                     $priceLevel $foo->getpriceLevel();
  102.                     $store $foo->getstore();
  103.                     $Status $foo->getStatus();
  104.                     $uniqueNumber $foo->geteventNum();
  105.                
  106.                
  107.                  
  108.             //throw new \Pimcore\Model\Element\ValidationException($o_parentId, 1234);   
  109.                  $parentData DataObject::getById($o_parentId);
  110.                  $po_type $parentData->geto_type();
  111.                    //throw new \Pimcore\Model\Element\ValidationException($po_type, 1234);   
  112. if($po_type != 'folder')
  113. {
  114.     // throw new \Pimcore\Model\Element\ValidationException($po_type."You are not allowed to update this object.", 12345);   
  115. }
  116.                     if($po_type == 'folder')
  117.                     {
  118.                         
  119.                         //throw new \Pimcore\Model\Element\ValidationException(" I am in.", 1234);   
  120.                             // $queryOne="select FLOOR(10000 + RAND() * 899999) AS random_num from object_price where 'eventNum' NOT IN (select eventNum from object_price WHERE eventNum IS NOT NULL) LIMIT 1";
  121.                             // $statmentEvnt = Db::get()->prepare($queryOne);
  122.                             // $statmentEvnt->execute();
  123.                             // $dataGetEvnt =$statmentEvnt->fetchAll();
  124.                             // $uniqueBumberPar=$dataGetEvnt[0]['random_num'];
  125.                             // $eventNumberSet=DataObject\PriceEvent::getById($pid);
  126.                             // $eventNumberSet->seteventNum($uniqueBumberPar);
  127.                             // $eventNumberSet->save();
  128.                             $tableOne "object_price";
  129.                             $query "select * from ".$tableOne." where o_parentId='".$pid."'";
  130.                             $statment Db::get()->prepare($query);
  131.                             $statment->execute();
  132.                             $dataGet =$statment->fetchAll();
  133.                             $totalResult count($dataGet); 
  134.                             if($totalResult 0)
  135.                             {
  136.                                 // throw new \Pimcore\Model\Element\ValidationException("if", 1234);
  137.                                 $m=0;
  138.                                 while($m count($dataGet))
  139.                                 {
  140.                                      $childId $dataGet[$m]['o_id'];
  141.                                      $m++;
  142.                                      $priceEventObjectUpdate DataObject::getById($childId);                
  143.                                      $priceEventObjectUpdate->seteventDesc($eventDesc);
  144.                                      $priceEventObjectUpdate->setstartDate($startDate);
  145.                                      $priceEventObjectUpdate->setendDate($endDate);
  146.                                      $priceEventObjectUpdate->seteventSeason($eventSeason);
  147.                                      $priceEventObjectUpdate->setpriceLevel($priceLevel);
  148.                                      $priceEventObjectUpdate->setstore($store);
  149.                                      $priceEventObjectUpdate->setStatus($Status);
  150.                                      $priceEventObjectUpdate->seteventNum($uniqueNumber);
  151.                                      $priceEventObjectUpdate->setchangeByPercentValue($statusForValue);
  152.                                      
  153.                                      
  154.                                      
  155.                                      
  156.                                      $masterSkuDetails1=$priceEventObjectUpdate->getitemMasterSKU();
  157.                                      foreach ($masterSkuDetails1 as $itemMasterDeatil1
  158.                                     {
  159.                                         $itemMasterskuid1$itemMasterDeatil1->getId();
  160.                                         $myObject DataObject::getById($itemMasterskuid1); 
  161.                                         $skuUpdateObject=$myObject->getsku();
  162.                                          $myObject DataObject::getById($itemMasterskuid1); 
  163.                                         $child_o_published $myObject->geto_published();
  164.                                         if(empty($child_o_published) || $child_o_published == 0)
  165.                                         {
  166.                                             throw new \Pimcore\Model\Element\ValidationException("Please select valid SKU."1234);
  167.                                         }
  168.                                         
  169.                                         if($myObject->getSalesInformation())
  170.                                         {
  171.                                             if($myObject->getSalesInformation()->getSaleInformation())
  172.                                             {
  173.                                                $sellingCost=$myObject->getSalesInformation()->getSaleInformation()->getsellingPrice();   
  174.                                                $originalSalePrice=$myObject->getSalesInformation()->getSaleInformation()->getoriginalSalePrice();   
  175.                                             }
  176.                                             else
  177.                                             {
  178.                                                 $sellingCost=0;
  179.                                                 $originalSalePrice0;
  180.                                             }
  181.                                         }
  182.                                         else
  183.                                         {
  184.                                           $sellingCost=0
  185.                                           $originalSalePrice 0;
  186.                                         }
  187.                                         $priceEventObjectUpdate->setOriginalPrice($originalSalePrice);
  188.                                         if($sellingCost == NULL || $sellingCost == 0)
  189.                                         {
  190.                                             throw new \Pimcore\Model\Element\ValidationException("Selling price is missing for".$itemMasterskuid1 " Object"1234);
  191.                                         }
  192.                                         elseif($skuUpdateObject == NULL)
  193.                                         {
  194.                                             throw new \Pimcore\Model\Element\ValidationException($itemMasterskuid1 " Object does not have sku number"1234);
  195.                                         }
  196.                                         else
  197.                                         {
  198.                                             if($statusForValue == "changeByPercentValue")
  199.                                             {
  200.                                                 if(($changeValue 999.99) && ($changeValue < -999.99))            
  201.                                                 {
  202.                                                     throw new \Pimcore\Model\Element\ValidationException("Percent should not be less then 999.99 and greter then -999.99"1234);
  203.                                                 }
  204.                                                 else
  205.                                                 {
  206.                                                     $resultUpdatePrecent = ($sellingCost * ($changeValue/100)) +$sellingCost
  207.                                                     $priceEventObjectUpdate->setchangeByValue($foo->getchangeByValue());
  208.                                                     $priceEventObjectUpdate->setCurrentPrice($sellingCost);
  209.                                                     $priceEventObjectUpdate->setfinalPrice($resultUpdatePrecent);
  210.                                                     $priceEventObjectUpdate->save();
  211.                                                 }
  212.                                                                     
  213.                                             }
  214.                                             if($statusForValue == "changeByPrice")
  215.                                             {
  216.                                                 if($changeValue )
  217.                                                 {
  218.                                                     throw new \Pimcore\Model\Element\ValidationException("Price should not be less then 0"1234); 
  219.                                                 }
  220.                                                 else
  221.                                                 {
  222.                                                     $resultUpdatePrice=$changeValue
  223.                                                     $priceEventObjectUpdate->setchangeByValue($foo->getchangeByValue());
  224.                                                     $priceEventObjectUpdate->setCurrentPrice($sellingCost);
  225.                                                     $priceEventObjectUpdate->setfinalPrice($resultUpdatePrice);
  226.                                                     $priceEventObjectUpdate->save();
  227.                                                 }
  228.                                                                
  229.                                             }
  230.                                         }
  231.                                     }
  232.                                     
  233.                                 }
  234.                             }
  235.                             else
  236.                             {
  237.                                 // throw new \Pimcore\Model\Element\ValidationException("else", 1234);
  238.                                 foreach ($masterSkuDetails as $itemMasterDeatil
  239.                                 {
  240.                                     $itemMasterskuid$itemMasterDeatil->getId(); 
  241.                                      $myObject DataObject::getById($itemMasterskuid); 
  242.                                         $child_o_published $myObject->geto_published();
  243.                                         if(empty($child_o_published) || $child_o_published == 0)
  244.                                         {
  245.                                             throw new \Pimcore\Model\Element\ValidationException("Please select valid SKU."1234);
  246.                                         }
  247.    
  248.                                     $skuNumber$itemMasterDeatil->getsku();
  249.                                     if($itemMasterDeatil->getSalesInformation())
  250.                                     {
  251.                                             if($itemMasterDeatil->getSalesInformation()->getSaleInformation())
  252.                                             {
  253.                                                $getSPrice=$itemMasterDeatil->getSalesInformation()->getSaleInformation()->getsellingPrice();   
  254.                                             }
  255.                                             else
  256.                                             {
  257.                                                 $getSPrice=0;
  258.                                             }
  259.                                     }
  260.                                     else
  261.                                     {
  262.                                       $getSPrice=0
  263.                                     } 
  264.                                     if($getSPrice == '0' || $getSPrice == NULL )
  265.                                     {
  266.                                         throw new \Pimcore\Model\Element\ValidationException("Selling price is missing for".$getSPrice " Object"1234);
  267.                                     }
  268.                                     elseif($skuNumber == NULL)
  269.                                     {
  270.                                         throw new \Pimcore\Model\Element\ValidationException($itemMasterskuid " Object does not have sku number"1234);
  271.                                         $setCode=$itemMasterDeatil->getId();
  272.                                         $query "delete from  object_relations_price where dest_id='".$itemMasterskuid."'and fieldname='itemMasterSKU' and src_id='".$pid."' ";
  273.                                         $stmt Db::get()->prepare($query);
  274.                                         $stmt->execute();
  275.                                     }
  276.                                     else
  277.                                     {
  278.                                         
  279.                                         $objectItemMasterSku = new DataObject\PriceEvent();
  280.                                         $objectItemMasterSku->setParent(DataObject::getById($pid)); 
  281.                                         $objectItemMasterSku->setKey(\Pimcore\Model\Element\Service::getValidKey($itemMasterskuid'object'));
  282.                                          
  283.                                         // $queryOne="select FLOOR(10000 + RAND() * 899999) AS random_num from object_price where 'eventNum' NOT IN (select eventNum from object_price WHERE eventNum IS NOT NULL) LIMIT 1";
  284.                                         // $statmentEvnt = Db::get()->prepare($queryOne);
  285.                                         // $statmentEvnt->execute();
  286.                                         // $dataGetEvnt =$statmentEvnt->fetchAll();
  287.                                         // $uniqueNumber=$dataGetEvnt[0]['random_num'];
  288.                                         
  289.                                         $objectItemMasterSku->seteventNum($uniqueNumber);
  290.                                         $objectItemMasterSku->seteventDesc($eventDesc);
  291.                                         $objectItemMasterSku->setstartDate($startDate);
  292.                                         $objectItemMasterSku->setendDate($endDate);
  293.                                         $objectItemMasterSku->seteventSeason($eventSeason);
  294.                                         $objectItemMasterSku->setpriceLevel($priceLevel);
  295.                                         $objectItemMasterSku->setstore($store);
  296.                                         $objectItemMasterSku->setStatus($Status);
  297.                                         $objectItemMasterSku->setchangeByPercentValue($statusForValue);
  298.                                         $objectItemMasterSku->setPublished(true);
  299.                                        
  300.                                         
  301.                                         // get child object
  302.                                         $myObject DataObject::getById($itemMasterskuid);
  303.                                         $sellingCost $myObject->getSalesInformation()->getSaleInformation()->getsellingPrice();
  304.                                         
  305.                                          $originalSalePrice=$myObject->getSalesInformation()->getSaleInformation()->getoriginalSalePrice(); 
  306.                                          
  307.                                          $objectItemMasterSku->setOriginalPrice($originalSalePrice);
  308.                                       
  309.                                         if($statusForValue == "changeByPercentValue")
  310.                                         {
  311.                                             if(($changeValue 999.99) && ($changeValue < -999.99))            
  312.                                             {
  313.                                                 throw new \Pimcore\Model\Element\ValidationException("Percent should not be less then 999.99 and greter then -999.99"1234);
  314.                                             }
  315.                                             else
  316.                                             {
  317.                                                 $result=($getSPrice * ($changeValue/100)) + $getSPrice;
  318.                                                 $objectItemMasterSku->setCurrentPrice($getSPrice);
  319.                                                 $objectItemMasterSku->setchangeByValue($changeValue);
  320.                                                 $objectItemMasterSku->setfinalPrice($result);
  321.                                                // $objectItemMasterSku->save();
  322.                                             }
  323.                                                              
  324.                                         }
  325.                                         if($statusForValue == "changeByPrice")
  326.                                         {
  327.                                              if($changeValue )
  328.                                             {
  329.                                                 throw new \Pimcore\Model\Element\ValidationException("Price should not be less then 0"1234); 
  330.                                             }
  331.                                             else
  332.                                             {
  333.                                                 //throw new \Pimcore\Model\Element\ValidationException($changeValue, 1234); 
  334.                                                 $result=$changeValue;
  335.                                                 $objectItemMasterSku->setCurrentPrice($getSPrice);
  336.                                                 $objectItemMasterSku->setchangeByValue($changeValue);
  337.                                                 $objectItemMasterSku->setfinalPrice($result);
  338.                                               //  $objectItemMasterSku->save(); 
  339.                                             }
  340.                                             
  341.                                         }
  342.                                         $objectItemMasterSku->save(); 
  343.                                         $newId $objectItemMasterSku->getId();
  344.                                          $j=1;   
  345.                                         $query "INSERT INTO `object_relations_price` (`src_id`, `dest_id`, `type`, `fieldname`, `index`, `ownertype`, `ownername`, `position`) VALUES ('".$newId."', '".$itemMasterskuid."', 'object', 'itemMasterSKU', '".$j."', 'object', 'child', '0');";
  346.                                         $stmt Db::get()->prepare($query);
  347.                                         $rdata =  $stmt->execute();
  348.                                         $j++;
  349.                                     }        
  350.                             
  351.                                 }         
  352.                             }   
  353.                     }
  354.                     else
  355.                     {
  356.                       //throw new \Pimcore\Model\Element\ValidationException("You are not allowed to update this object.", 1234);   
  357.                     }
  358.                     // else
  359.                     // {
  360.                     //                 $priceEventObjectUpdate = DataObject::getById($pid);                
  361.                                     
  362.                     //                 $masterSkuDetails1=$priceEventObjectUpdate->getitemMasterSKU();
  363.                     //                  foreach ($masterSkuDetails1 as $itemMasterDeatil1) 
  364.                     //                 {
  365.                     //                     $itemMasterskuid1= $itemMasterDeatil1->getId();
  366.                     //                     $myObject = DataObject::getById($itemMasterskuid1); 
  367.                     //                     $skuUpdateObject=$myObject->getsku();
  368.                                         
  369.                     //                     if($myObject->getSalesInformation())
  370.                     //                     {
  371.                     //                         if($myObject->getSalesInformation()->getSaleInformation())
  372.                     //                         {
  373.                     //                            $sellingCost=$myObject->getSalesInformation()->getSaleInformation()->getsellingPrice();   
  374.                     //                         }
  375.                     //                         else
  376.                     //                         {
  377.                     //                             $sellingCost=0;
  378.                     //                         }
  379.                     //                     }
  380.                     //                     else
  381.                     //                     {
  382.                     //                       $sellingCost=0; 
  383.                     //                     } 
  384.                     //                     if($sellingCost == NULL || $sellingCost == 0)
  385.                     //                     {
  386.                     //                         throw new \Pimcore\Model\Element\ValidationException("Selling price is missing for".$itemMasterskuid1 . " Object", 1234);
  387.                     //                     }
  388.                     //                     elseif($skuUpdateObject == NULL)
  389.                     //                     {
  390.                     //                         throw new \Pimcore\Model\Element\ValidationException($itemMasterskuid1 . " Object does not have sku number", 1234);
  391.                     //                     }
  392.                     //                     else
  393.                     //                     {
  394.                     //                         if($statusForValue == "changeByPercentValue")
  395.                     //                         {
  396.                     //                             if(($changeValue < 999.99) && ($changeValue < -999.99))            
  397.                     //                             {
  398.                     //                                 throw new \Pimcore\Model\Element\ValidationException("Percent should not be less then 999.99 and greter then -999.99", 1234);
  399.                     //                             }
  400.                     //                             else
  401.                     //                             {
  402.                     //                                 $resultUpdatePrecent = ($sellingCost * ($changeValue/100)) +$sellingCost; 
  403.                     //                                 $priceEventObjectUpdate->setchangeByValue($foo->getchangeByValue());
  404.                     //                                 $priceEventObjectUpdate->setCurrentPrice($sellingCost);
  405.                     //                                 $priceEventObjectUpdate->setfinalPrice($resultUpdatePrecent);
  406.                     //                                 $priceEventObjectUpdate->save();
  407.                     //                             }
  408.                                                                     
  409.                     //                         }
  410.                     //                         if($statusForValue == "changeByPrice")
  411.                     //                         {
  412.                     //                             if($changeValue < 0 )
  413.                     //                             {
  414.                     //                                 throw new \Pimcore\Model\Element\ValidationException("Price should not be less then 0", 1234); 
  415.                     //                             }
  416.                     //                             else
  417.                     //                             {
  418.                     //                                 $resultUpdatePrice=$changeValue; 
  419.                     //                                 $priceEventObjectUpdate->setchangeByValue($foo->getchangeByValue());
  420.                     //                                 $priceEventObjectUpdate->setCurrentPrice($sellingCost);
  421.                     //                                 $priceEventObjectUpdate->setfinalPrice($resultUpdatePrice);
  422.                     //                                 $priceEventObjectUpdate->save();
  423.                     //                             }
  424.                                                                
  425.                     //                         }
  426.                     //                     }
  427.                     //                 }
  428.                     // }
  429.             }
  430.         }
  431.         
  432.     }
  433.     
  434.     public function onPreAdd(ElementEventInterface $e)
  435.     {
  436.     }
  437.     public function onPreUpdate(ElementEventInterface $e)
  438.     {
  439.        
  440.       if($e instanceof AssetEvent
  441.         {
  442.             $foo $e->getAsset(); 
  443.         }
  444.          else if ($e instanceof DocumentEvent)
  445.         {
  446.             $foo $e->getDocument(); 
  447.         } 
  448.         else if ($e instanceof DataObjectEvent
  449.         {
  450.              // do something with the object
  451.              $foo $e->getObject();          
  452.              $pid =  $foo->getId(); 
  453.              $p_id=1;      
  454.              $claname '';
  455.              $otype $foo->geto_type();
  456.              $o_parentId$foo->getParentId();
  457.       
  458.  $user = \Pimcore\Tool\Admin::getCurrentUser();
  459.                 //$foo.reload();
  460.             if($otype == 'object')
  461.             {
  462.                  $o_published =$foo->geto_published();
  463.                 $claname $foo->geto_className();  
  464.  $tablename "object_price";
  465.                  $sql "select * from ".$tablename." where  o_id = '".$pid."' ";
  466.                            $stmt Db::get()->prepare($sql);
  467.                          $stmt->execute();
  468.                     $dataI =$stmt->fetchAll();
  469.             $o_published=$dataI[0]['o_published'];
  470.             }                         
  471.             if(($claname == 'priceEvent' || $claname == 'PriceEvent' )  && $user != null && $o_published == 1)
  472.             {
  473.   $o_published $foo->geto_published();
  474.         $eventSeason $foo->geteventSeason();
  475.         $endDate $foo->getendDate();
  476.  $table "object_price";
  477.         
  478.          $sql "select * from ".$table." where oo_id='".$pid."'";
  479.                            $stmt Db::get()->prepare($sql);
  480.                          $stmt->execute();
  481.                     $data =$stmt->fetchAll();
  482.                     $dbstatus $data[0]['Status'];
  483.                 $Status $foo->getStatus();
  484. $mainobject DataObject::getById($pid);
  485. $mainstatus$mainobject->getStatus();
  486. $changeValue=$foo->getchangeByValue();
  487. $userOwner $foo->getuserOwner();
  488. //throw new \Pimcore\Model\Element\ValidationException($userOwner, 1234);
  489.                     $statusForValue=$foo->getchangeByPercentValue();
  490. $priceEventObjectUpdate DataObject::getById($pid); 
  491.                                                // $objectItemMasterSku->setchangeByPriceInput($statusForValue);
  492.                                                
  493.                                   //  $priceEventObjectUpdate->setfinalPrice();
  494. //throw new \Pimcore\Model\Element\ValidationException($pid." ".$Status." ".$dbstatus, 1234);
  495. if($eventSeason == '7' || $eventSeason == 7)
  496. {
  497.     if($endDate == '')
  498.     {
  499.         throw new \Pimcore\Model\Element\ValidationException("Please select end date."1234);
  500.     }
  501. }
  502. if($dbstatus == 'Approved' && $userOwner 0)
  503. {
  504.   throw new \Pimcore\Model\Element\ValidationException("You are not allowed to do changes."1234); 
  505. }
  506. $masterSkuDetails=$priceEventObjectUpdate->getitemMasterSKU();
  507. $mypObject ='';
  508. foreach ($masterSkuDetails as $itemMasterDeatil
  509.                                 {
  510.                                     $itemMasterskuid$itemMasterDeatil->getId(); 
  511.                                      $mypObject DataObject::getById($itemMasterskuid); 
  512.                                 }
  513. if($mypObject)
  514. {
  515.  if($mypObject->getSalesInformation())
  516.                                     {
  517.                                             if($mypObject->getSalesInformation()->getSaleInformation())
  518.                                             {
  519.                                                $getSPrice=$mypObject->getSalesInformation()->getSaleInformation()->getsellingPrice();   
  520.                                             }
  521.                                             else
  522.                                             {
  523.                                                 $getSPrice=0;
  524.                                             }
  525.                                     }
  526.                                     else
  527.                                     {
  528.                                       $getSPrice=0
  529.                                     } 
  530. }
  531.                                     if($statusForValue == "changeByPercentValue")
  532.                                         {
  533.                                             if(($changeValue 999.99) && ($changeValue < -999.99))            
  534.                                             {
  535.                                                 throw new \Pimcore\Model\Element\ValidationException("Percent should not be less then 999.99 and greter then -999.99"1234);
  536.                                             }
  537.                                             else
  538.                                             {
  539.                                                 $result=($getSPrice * ($changeValue/100)) + $getSPrice;
  540.                                                // $objectItemMasterSku->setCurrentPrice($getSPrice);
  541.                                                // $objectItemMasterSku->setchangeByValue($changeValue);
  542.                                                 $priceEventObjectUpdate->setfinalPrice($result);
  543.                                                // $objectItemMasterSku->save();
  544.                                             }
  545.                                                              
  546.                                         }
  547.                                         if($statusForValue == "changeByPrice")
  548.                                         {
  549.                                              if($changeValue )
  550.                                             {
  551.                                                 throw new \Pimcore\Model\Element\ValidationException("Price should not be less then 0"1234); 
  552.                                             }
  553.                                             else
  554.                                             {
  555.                                                 //throw new \Pimcore\Model\Element\ValidationException($changeValue, 1234); 
  556.                                                 $result=$changeValue;
  557.                                                // $objectItemMasterSku->setCurrentPrice($getSPrice);
  558.                                                 //$objectItemMasterSku->setchangeByValue($changeValue);
  559.                                                 $priceEventObjectUpdate->setfinalPrice($result);
  560.                                               //  $objectItemMasterSku->save(); 
  561.                                             }
  562.                                             
  563.                                         }
  564.                     //throw new \Pimcore\Model\Element\ValidationException($o_published, 1234); 
  565.                 
  566.               //  throw new \Pimcore\Model\Element\ValidationException($pid." ".$Status." ".$mainstatus, 1234); 
  567.                 if($Status == 'Approved')
  568.                 {
  569.                    // throw new \Pimcore\Model\Element\ValidationException("You are not allowed to do changes.", 1234); 
  570.                 }
  571.             }
  572.         }
  573.     }
  574. }