Wampas Posted July 18, 2017 Share Posted July 18, 2017 Hello, I have two modules. One module is working a long time already. I have bought another module and trying to install and I have got this error: The following module(s) could not be installed properly: ba_prestashop_invoice : Unable to install override: The method setLastInvoiceNumber in the class Order is already overridden by the module modrefchange version 1.5.5.1 at 2016-11-26 03:12:16 . As I understand both modules are trying to overide files Order.php, OrderInvoice.php and OrderPayment.php files. Right now I have override\classes\order\Order.php file content like this : <?php class Order extends OrderCore { /* * module: modrefchange * date: 2016-11-26 03:12:16 * version: 1.5.5.1 */ public function add($autodate = true, $null_values = true) { $cart = new Cart($this->id_cart); Hook::exec('actionBeforeAddOrder', array('order'=>$this,'cart'=>$cart)); if (ObjectModel::add($autodate, $null_values)) return SpecificPrice::deleteByIdCart($this->id_cart); return false; } /* * module: modrefchange * date: 2016-11-26 03:12:16 * version: 1.5.5.1 */ public static function setLastInvoiceNumber($order_invoice_id, $id_shop) { if (!$order_invoice_id) return false; $number = Configuration::get('PS_INVOICE_START_NUMBER', null, null, $id_shop); if ($number) Configuration::updateValue('PS_INVOICE_START_NUMBER', false, false, null, $id_shop); $order_invoice = new OrderInvoice($order_invoice_id); $order = new Order($order_invoice->id_order); $cart = new Cart($order->id_cart); if($ref = Hook::exec('actionBeforeAddOrderInvoice', array('order_invoice'=>$order_invoice,'order'=>$order,'cart'=>$cart))) $number = $ref; $sql = 'UPDATE `'._DB_PREFIX_.'order_invoice` SET number ='; if ($number) $sql .= (int)$number; else $sql .= '(SELECT new_number FROM (SELECT (MAX(`number`) + 1) AS new_number FROM `'._DB_PREFIX_.'order_invoice`) AS result)'; $sql .=' WHERE `id_order_invoice` = '.(int)$order_invoice_id; return Db::getInstance()->execute($sql); } /* * module: modrefchange * date: 2016-11-26 03:12:16 * version: 1.5.5.1 */ public function setDeliveryNumber($order_invoice_id, $id_shop) { if (!$order_invoice_id) return false; $id_shop = shop::getTotalShops() > 1 ? $id_shop : null; $number = Configuration::get('PS_DELIVERY_NUMBER', null, null, $id_shop); if ($number) Configuration::updateValue('PS_DELIVERY_NUMBER', false, false, null, $id_shop); $order_invoice = new OrderInvoice($order_invoice_id); $order = new Order($order_invoice->id_order); $cart = new Cart($order->id_cart); if($ref = Hook::exec('actionBeforeAddDeliveryNumber', array('order'=>$order,'cart'=>$cart,'number'=>$number))) $number = $ref; $sql = 'UPDATE `'._DB_PREFIX_.'order_invoice` SET delivery_number ='; if ($number) $sql .= (int)$number; else $sql .= '(SELECT new_number FROM (SELECT (MAX(`delivery_number`) + 1) AS new_number FROM `'._DB_PREFIX_.'order_invoice`) AS result)'; $sql .=' WHERE `id_order_invoice` = '.(int)$order_invoice_id; return Db::getInstance()->execute($sql); } } override\classes\order\OrderInvoice.php file content like this : <?php class OrderInvoice extends OrderInvoiceCore { /* * module: modrefchange * date: 2016-11-26 03:12:17 * version: 1.5.5.1 */ public function add($autodate = true, $null_values = true) { $order = new Order($this->id_order); $cart = new Cart($order->id_cart); Hook::exec('actionBeforeAddOrderInvoice', array('order_invoice'=>$this, 'order'=>$order,'cart'=>$cart)); return parent::add($autodate, $null_values); } } and override\classes\order\OrderPayment.php file content like this : <?php class OrderPayment extends OrderPaymentCore { public static $definition = array( 'table' => 'order_payment', 'primary' => 'id_order_payment', 'fields' => array( 'order_reference' => array('type' => self::TYPE_STRING, 'validate' => 'isAnything', 'size' => 100), 'id_currency' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), 'amount' => array('type' => self::TYPE_FLOAT, 'validate' => 'isNegativePrice', 'required' => true), 'payment_method' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'), 'conversion_rate' => array('type' => self::TYPE_INT, 'validate' => 'isFloat'), 'transaction_id' => array('type' => self::TYPE_STRING, 'validate' => 'isAnything', 'size' => 254), 'card_number' => array('type' => self::TYPE_STRING, 'validate' => 'isAnything', 'size' => 254), 'card_brand' => array('type' => self::TYPE_STRING, 'validate' => 'isAnything', 'size' => 254), 'card_expiration' => array('type' => self::TYPE_STRING, 'validate' => 'isAnything', 'size' => 254), 'card_holder' => array('type' => self::TYPE_STRING, 'validate' => 'isAnything', 'size' => 254), 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), ), ); } Right now I am trying to install new module invoice advanced and this module contains 3 of four the same files with contents: Order.php: class Order extends OrderCore { // update invoice number public static function setLastInvoiceNumber($order_invoice_id, $id_shop) { if (!$order_invoice_id) { return false; } /////////// require_once(_PS_MODULE_DIR_ . "ba_prestashop_invoice/includes/helper.php"); $helper = new BAInvoiceHelper(); if ($helper->isEnabledCustomNumber('INVOICE') == false) { return parent::setLastInvoiceNumber($order_invoice_id, $id_shop); } return $helper->setLastInvoiceNumber($order_invoice_id, $id_shop); } public function setDeliveryNumber($order_invoice_id, $id_shop) { if (!$order_invoice_id) { return false; } /////////// require_once(_PS_MODULE_DIR_ . "ba_prestashop_invoice/includes/helper.php"); $helper = new BAInvoiceHelper(); if ($helper->isEnabledCustomNumber('INVOICE') == false) { return parent::setDeliveryNumber($order_invoice_id, $id_shop); } return $helper->setDeliveryNumber($order_invoice_id, $id_shop); } public static function generateReference() { $id_shop = (int) Context::getContext()->shop->id; /////////// require_once(_PS_MODULE_DIR_ . "ba_prestashop_invoice/includes/helper.php"); $helper = new BAInvoiceHelper(); if ($helper->isEnabledCustomNumber('ORDER') == false) { return parent::generateReference(); } return $helper->generateReference($id_shop); } } OrderInvoice.php: class OrderInvoice extends OrderInvoiceCore { // hien thi format invoice number ra ben ngoai public function getInvoiceNumberFormatted($id_lang, $id_shop = null) { /////////// require_once(_PS_MODULE_DIR_ . "ba_prestashop_invoice/includes/helper.php"); $helper = new BAInvoiceHelper(); $setting = Configuration::get("invoice_customnumber_setting", null, null, $id_shop); $setting = Tools::jsonDecode($setting, true); if ($helper->isEnabledCustomNumber('INVOICE') == true) { return $helper->formatInvoicebyNumber($this->number, $this->date_add, $id_lang, $id_shop); } else { return '#'.Configuration::get('PS_INVOICE_PREFIX', $id_lang, null, $id_shop).sprintf('%06d', $this->number); } } // hien thi format invoice number ra ben ngoai public function getDeliveryNumberFormatted($id_lang, $id_shop = null) { /////////// require_once(_PS_MODULE_DIR_ . "ba_prestashop_invoice/includes/helper.php"); $helper = new BAInvoiceHelper(); if ($helper->isEnabledCustomNumber('DELIVERY') == true) { return $helper->formatDeliverybyNumber($this->delivery_number, $this->delivery_date, $id_lang, $id_shop); } else { $pre = Configuration::get('PS_DELIVERY_PREFIX', $id_lang, null, $id_shop); return '#'.$pre.sprintf("%06d", $this->delivery_number); } } } and OrderPayment.php: class OrderPayment extends OrderPaymentCore { // khoi tao tu ObjectModel public function __construct($id = null, $id_lang = null, $id_shop = null) { self::$definition['fields']['order_reference']['size'] = 32; parent::__construct($id, $id_lang, $id_shop); } } I need help to combine these overrides and short instruction how to install the second module. As I know I need delete index.php in override\classes\order catalogue after manual override file creation. Please help. Link to comment Share on other sites More sharing options...
Wampas Posted July 18, 2017 Author Share Posted July 18, 2017 anyone? Link to comment Share on other sites More sharing options...
joseantgv Posted July 19, 2017 Share Posted July 19, 2017 Why don't you ask the developer to do it for you? Link to comment Share on other sites More sharing options...
Wampas Posted July 19, 2017 Author Share Posted July 19, 2017 The modeofrefrence module is free and I will not get a support. The Advance Invoice, Delivery PDF Builder+Custom Number Pro module developers asks to resolve the issue by myself that their module could be installed. I as migrating data from old 1.5 version prestashop and their all orders number was in number format and not in random letters. I need that both modules would work because I will need to to last data synchronisation before going to production with new e-shop version. Link to comment Share on other sites More sharing options...
Scully Posted July 20, 2017 Share Posted July 20, 2017 You could join the overrides into one. However, it is very tricky. You have to read all the code, understand what it does and the join the funcionality from two overrides into one. There is no automated way to do this. And of course: Module updates wouln't work anymore without manual intervention. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now