diff --git a/classes/Product.php b/classes/Product.php index 2a5e58053..267005dff 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -4712,7 +4712,7 @@ class ProductCore extends ObjectModel public function addWs($autodate = true, $null_values = false) { $success = parent::add($autodate, $null_values); - if ($success) + if ($success && Configuration::get('PS_SEARCH_INDEXATION')) Search::indexation(false, $this->id); return $success; } @@ -4720,7 +4720,7 @@ class ProductCore extends ObjectModel public function updateWs($null_values = false) { $success = parent::update($null_values); - if ($success) + if ($success && Configuration::get('PS_SEARCH_INDEXATION')) Search::indexation(false, $this->id); return $success; } diff --git a/classes/Tag.php b/classes/Tag.php index e96621d35..ffb393a13 100644 --- a/classes/Tag.php +++ b/classes/Tag.php @@ -200,7 +200,8 @@ class TagCore extends ObjectModel if ($result) { $result &= Db::getInstance()->execute('INSERT INTO '._DB_PREFIX_.'product_tag (id_product, id_tag) VALUES '.implode(',', $ids)); - $result &= Search::indexation(false); + if (Configuration::get('PS_SEARCH_INDEXATION')) + $result &= Search::indexation(false); } } return $result; diff --git a/controllers/admin/AdminImportController.php b/controllers/admin/AdminImportController.php index 1e68316df..7e670a177 100644 --- a/controllers/admin/AdminImportController.php +++ b/controllers/admin/AdminImportController.php @@ -1397,7 +1397,8 @@ class AdminImportControllerCore extends AdminController } - Search::indexation(true); + if (Configuration::get('PS_SEARCH_INDEXATION')) + Search::indexation(true); $this->closeCsvFile($handle); } diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index cc94921bd..b52ae075b 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -455,7 +455,7 @@ class AdminProductsControllerCore extends AdminController else { Hook::exec('actionProductAdd', array('product' => $product)); - if (in_array($product->visibility, array('both', 'search'))) + if (in_array($product->visibility, array('both', 'search')) && Configuration::get('PS_SEARCH_INDEXATION')) Search::indexation(false, $product->id); $this->redirect_after = self::$currentIndex.(Tools::getIsset('id_category') ? '&id_category='.(int)Tools::getValue('id_category') : '').'&conf=19&token='.$this->token; } @@ -1483,7 +1483,7 @@ class AdminProductsControllerCore extends AdminController else { Hook::exec('actionProductAdd', array('product' => $this->object)); - if (in_array($this->object->visibility, array('both', 'search'))) + if (in_array($this->object->visibility, array('both', 'search')) && Configuration::get('PS_SEARCH_INDEXATION')) Search::indexation(false, $this->object->id); } @@ -1610,7 +1610,7 @@ class AdminProductsControllerCore extends AdminController { Hook::exec('actionProductUpdate', array('product' => $object)); - if (in_array($object->visibility, array('both', 'search'))) + if (in_array($object->visibility, array('both', 'search')) && Configuration::get('PS_SEARCH_INDEXATION')) Search::indexation(false, $object->id); // Save and preview diff --git a/controllers/admin/AdminSearchConfController.php b/controllers/admin/AdminSearchConfController.php index 406e4227f..baabacc6f 100644 --- a/controllers/admin/AdminSearchConfController.php +++ b/controllers/admin/AdminSearchConfController.php @@ -73,7 +73,16 @@ class AdminSearchConfControllerCore extends AdminController $this->l('Add missing products to index.').'
-> '. $this->l('Re-build entire index.').'

- '.$this->l('You can set a cron job that will rebuild your index using the following URL:').' '.$cron_url.'' + '.$this->l('You can set a cron job that will rebuild your index using the following URL:').' '.$cron_url.'', + 'fields' => array( + 'PS_SEARCH_INDEXATION' => array( + 'title' => $this->l('Indexation'), + 'validation' => 'isBool', + 'type' => 'bool', + 'cast' => 'intval', + 'desc' => $this->l('Enable automatic indexation of the products. If you enable this feature, the products will be indexed in the search automatically when they are saved, but if the feature is disabled, you will have to index the products manually by using the links provided in this fieldset.') + ) + ) ), 'search' => array( 'title' => $this->l('Search'), diff --git a/install-dev/upgrade/sql/1.5.0.14.sql b/install-dev/upgrade/sql/1.5.0.14.sql index 41d61de9d..64ada0cd0 100644 --- a/install-dev/upgrade/sql/1.5.0.14.sql +++ b/install-dev/upgrade/sql/1.5.0.14.sql @@ -22,4 +22,6 @@ CREATE TABLE IF NOT EXISTS `PREFIX_order_invoice_tax` ( ) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; ALTER TABLE `PREFIX_order_invoice` -ADD `shipping_tax_computation_method` INT NOT NULL AFTER `total_shipping_tax_incl`; \ No newline at end of file +ADD `shipping_tax_computation_method` INT NOT NULL AFTER `total_shipping_tax_incl`; + +INSERT INTO `PREFIX_configuration`(`name`, `value`, `date_add`, `date_upd`) VALUES ('PS_SEARCH_INDEXATION', '1', NOW(), NOW());