1

I want to avoid modifing every data from a SalesOrder when the status equals "Cancelled", I get it to work with the part that involves SalesOrder info data, but I can`t get it to work with product part... any ideas?

$pedido = SalesOrder_Record_Model::getInstanceById($entityId);

$vtEntityDelta = new VTEntityDelta ();

$anterior = $vtEntityDelta->getOldValue($entity->getModuleName(), $entityId, "sostatus");
$actual = $pedido->get("sostatus");
$VTIGER_BULK_SAVE_MODE = true;  

if($anterior == "Approved" || $anterior == "Cancelled" || (($actual == "Approved" || $actual == "Cancelled") && (!$vtEntityDelta->hasChanged($entity->getModuleName(), $entityId, 'sostatus')))){
    foreach ($pedido->getModule()->getFields() as $field)
        if($vtEntityDelta->hasChanged($entity->getModuleName(), $entityId, $field->getName()))
            $pedido->set($field->getName(), $vtEntityDelta->getOldValue($entity->getModuleName(), $entityId, $field->getName()));
    $pedido->set("mode","edit");
    $pedido->save();
}

That works for info data as I was saying, some has any idea about this??

Thanks!

Manolo
  • 125
  • 2
  • 10
  • 1
    Please share that where you were trying to stop Product entity to be updated? Share file name with actual path and also code what you have tried for product module so i can provide you my suggestions – Milan Malani Sep 05 '16 at 18:44
  • Hi, I was able to solve this problem, I don't remember how at the moment but thx any way for your response – Manolo Sep 16 '16 at 03:05

0 Answers0