Index: branches/5.2.x/units/product_options/product_options_event_handler.php =================================================================== diff -u -N -r14986 -r15061 --- branches/5.2.x/units/product_options/product_options_event_handler.php (.../product_options_event_handler.php) (revision 14986) +++ branches/5.2.x/units/product_options/product_options_event_handler.php (.../product_options_event_handler.php) (revision 15061) @@ -1,6 +1,6 @@ getEventParam('id'); $temp_id = $event->getEventParam('temp_id'); - if ($id == $temp_id) return; + if ( $id == $temp_id ) { + return; + } - $poc_table = $this->Application->GetTempName(TABLE_PREFIX.'ProductOptionCombinations', 'prefix:p'); - $query = 'SELECT * FROM '.$poc_table; - $combs = $this->Conn->Query($query); + $poc_table = $this->Application->GetTempName(TABLE_PREFIX . 'ProductOptionCombinations', 'prefix:p'); + + $sql = 'SELECT * + FROM ' . $poc_table; + $combs = $this->Conn->Query($sql); + foreach ($combs as $a_comb) { $comb_data = unserialize($a_comb['Combination']); - $n_combs = array(); - foreach ($comb_data as $key => $val) - { + $n_combs = array (); + foreach ($comb_data as $key => $val) { $n_key = $key == $temp_id ? $id : $key; $n_combs[$n_key] = $val; } ksort($n_combs); $n_combs = serialize($n_combs); $n_crc = crc32($n_combs); - $query = 'UPDATE '.$poc_table.' SET - Combination = '.$this->Conn->qstr($n_combs).', CombinationCRC = '.$n_crc.' WHERE CombinationId = '.$a_comb['CombinationId']; - $this->Conn->Query($query); + $sql = 'UPDATE ' . $poc_table . ' + SET + Combination = ' . $this->Conn->qstr($n_combs) . ', + CombinationCRC = ' . $n_crc . ' + WHERE CombinationId = ' . $a_comb['CombinationId']; + $this->Conn->Query($sql); } } - function OnAfterClone(&$event) + /** + * Occurs after an item has been cloned + * Id of newly created item is passed as event' 'id' param + * + * @param kEvent $event + * @return void + * @access protected + */ + protected function OnAfterClone(kEvent &$event) { + parent::OnAfterClone($event); + $id = $event->getEventParam('id'); $org_id = $event->getEventParam('original_id'); // storing original to new ids mapping to use in poc:OnBeforeClone $options_mapping = $this->Application->GetVar('poc_mapping'); - if (!$options_mapping) $options_mapping = array(); + if ( !$options_mapping ) { + $options_mapping = array (); + } + $options_mapping[$org_id] = $id; $this->Application->SetVar('poc_mapping', $options_mapping); }