<?php class Product extends ProductCore { public static function changeAccessoriesForProduct($accessories_id, $product_id) { foreach ($accessories_id as $id_product_2) { Db::getInstance()->insert('accessory', array( 'id_product_1' => (int)$product_id, 'id_product_2' => (int)$id_product_2 )); // next 3 lines added to mirror for both ways relation Db::getInstance()->insert('accessory', array( 'id_product_1' => (int)$id_product_2, 'id_product_2' => (int)$product_id, )); } } public function deleteAccessories() { // the next line is commented by Vito // return Db::getInstance()->delete('accessory', 'id_product_1 = '.(int)$this->id); // next 3 lines added for removing of both relations $res = Db::getInstance()->delete('accessory', 'id_product_1 = '.(int)$this->id); $res &= Db::getInstance()->delete('accessory', 'id_product_2 = '.(int)$this->id); return $res; } public function deleteFromAccessories() { // the next line is commented by Vito // return Db::getInstance()->delete('accessory', 'id_product_2 = '.(int)$this->id); // next line is added for removing of both mirorred relations return $this->deleteAccessories(); } }
I try to add this Code in /override/classes/ but it not work with 1.7.6.2. The cache is empty. Anyone an idea?