Jump to content

An error occurred while updating the specific price


Recommended Posts

hi there - using the latest version of PS.

 

when I go into create a specific price rule for a product - discount or dollar amount doesn't matter - I get this error -

 

'an error occurred while updating the specific price'

 

Now when I go to 'catalogue price rules' and attempt to create a price rule I get this error -

 

'an error occurred while updating an object. specific_price_rule (unknown column 'reduction_tax' in 'field list').

 

I feel these are related to each other.  I am completely unable to apply a discount to any product - the only way to do it currently is by creating a cart rule and giving customers a voucher code to enter!

 

I have done lots of web searching, and realised if I inserted column 'reduction_tax' in the database at 'specific_price_rule', that error goes away and it tells me it was successful when I click 'save' - but the discount never applies. 

 

However the error for the product specific price rule above still occurs.

 

I have checked the PS schema database and in specific_price_rule there is no such column 'reduction_tax' required - but PS error is saying I need to have it?

 

 

can anyone please help me?

Edited by mik01 (see edit history)
Link to comment
Share on other sites

// Check if a specific price has been submitted
		if (!Tools::getIsset('submitPriceAddition'))
			return;

		$id_product = Tools::getValue('id_product');
		$id_product_attribute = Tools::getValue('sp_id_product_attribute');
		$id_shop = Tools::getValue('sp_id_shop');
		$id_currency = Tools::getValue('sp_id_currency');
		$id_country = Tools::getValue('sp_id_country');
		$id_group = Tools::getValue('sp_id_group');
		$id_customer = Tools::getValue('sp_id_customer');
		$price = Tools::getValue('leave_bprice') ? '-1' : Tools::getValue('sp_price');
		$from_quantity = Tools::getValue('sp_from_quantity');
		$reduction = (float)(Tools::getValue('sp_reduction'));
		$reduction_tax = Tools::getValue('sp_reduction_tax');
		$reduction_type = !$reduction ? 'amount' : Tools::getValue('sp_reduction_type');
		$from = Tools::getValue('sp_from');
		if (!$from)
			$from = '0000-00-00 00:00:00';
		$to = Tools::getValue('sp_to');
		if (!$to)
			$to = '0000-00-00 00:00:00';

		if ($reduction_type == 'percentage' && ((float)$reduction <= 0 || (float)$reduction > 100))
			$this->errors[] = Tools::displayError('Submitted reduction value (0-100) is out-of-range');
		elseif ($this->_validateSpecificPrice($id_shop, $id_currency, $id_country, $id_group, $id_customer, $price, $from_quantity, $reduction, $reduction_type, $from, $to, $id_product_attribute))
		{
			$specificPrice = new SpecificPrice();
			$specificPrice->id_product = (int)$id_product;
			$specificPrice->id_product_attribute = (int)$id_product_attribute;
			$specificPrice->id_shop = (int)$id_shop;
			$specificPrice->id_currency = (int)($id_currency);
			$specificPrice->id_country = (int)($id_country);
			$specificPrice->id_group = (int)($id_group);
			$specificPrice->id_customer = (int)$id_customer;
			$specificPrice->price = (float)($price);
			$specificPrice->from_quantity = (int)($from_quantity);
			$specificPrice->reduction = (float)($reduction_type == 'percentage' ? $reduction / 100 : $reduction);
			$specificPrice->reduction_tax = $reduction_tax;
			$specificPrice->reduction_type = $reduction_type;
			$specificPrice->from = $from;
			$specificPrice->to = $to;
			if (!$specificPrice->add())
				$this->errors[] = Tools::displayError('An error occurred while updating the specific price.');

array(
					'type' => 'select',
					'label' => $this->l('Reduction with or without taxes'),
					'name' => 'reduction_tax',
					'align' => 'center',
					'options' => array(
						'query' => array(
										array('lab' => $this->l('Tax included'), 'val' => 1),
										array('lab' => $this->l('Tax excluded'), 'val' => 0),
									),
						'id' => 'val',
						'name' => 'lab',

in my adminspecificpricerulecontroller file, I see the following reference to reduction_tax

 

I think I am close to working this out, but still don't understand why there is a reference to reduction_tax, yet the database schema doesn't reference this at all?

 

of course it is required - you must choose either tax inc or tax ex for the discount to apply.

 

In adminproductscontroller I also see the second set of code..

Edited by mik01 (see edit history)
  • Like 1
Link to comment
Share on other sites

array(
					'type' => 'select',
					'label' => $this->l('Reduction with or without taxes'),
					'name' => 'reduction_tax',
					'align' => 'center',
					'options' => array(
						'query' => array(
										array('lab' => $this->l('Tax included'), 'val' => 1),
										array('lab' => $this->l('Tax excluded'), 'val' => 0),
									),
						'id' => 'val',
						'name' => 'lab',
					)
				),

ok so I further worked out that between 1.6.0.9 and 1.6.0.11 there was an addition of the following code in adminspecificpricerulecontroller at line 272

 

undoubtedly I have some sort of databse issue - but where does the column 'reduction_tax' fit in? is it ps_specific_price or ps_specific_price_rule etc etc?

 

how can look at a database and let me know what it should look like?

Link to comment
Share on other sites

I fixed it!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

 

I needed to add column 'reduction_tax' into both specific_price AND specific_price_rule

 

when I copied the database over it was obviously missing these 2 little pieces.

 

SOLVED!

  • Like 1
Link to comment
Share on other sites

  • 4 weeks later...

Hello , 

 

i am having the same problem and i am trying add column 'reduction_tax' into both specific_price AND specific_price_rule in it but it gives me this below error can some one please help me 

 

Error

There seems to be an error in your SQL query. The MySQL server error output below, if there is any, may also help you in diagnosing the problem

ERROR: Unclosed quote @ 58
STR: '
SQL: ALTER TABLE `ps_specific_price` ADD `reduction_tax` ENUM(\'amount\',\'percentage\') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL
 

SQL query:

ALTER TABLE `ps_specific_price` ADD `reduction_tax` ENUM(\'amount\',\'percentage\') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL

MySQL said: b_help.png

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\'amount\',\'percentage\') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL' at line 1 

Link to comment
Share on other sites

  • 4 weeks later...
  • 1 year later...

 

ALTER TABLE `ps_specific_price` ADD `reduction_tax` ENUM('amount','percentage') NOT NULL AFTER `reduction`;
ALTER TABLE `ps_specific_price_rule` ADD `reduction_tax` ENUM('amount','percentage') NOT NULL AFTER `reduction`;

 

 

I added that code in SQL but when I add specific price for any product it is not visible in product page. If I add if in the cart I can see the reduced price but not in product page. Example: http://iskambg.com/avto-aksesoari/1031-%D0%B0%D0%BD%D0%B0%D1%82%D0%BE%D0%BC%D0%B8%D1%87%D0%BD%D0%B0-%D0%BE%D0%B1%D0%BB%D0%B5%D0%B3%D0%B0%D0%BB%D0%BA%D0%B0-%D0%B7%D0%B0-%D0%BA%D1%80%D1%8A%D1%81%D1%82-%D1%81%D1%82%D0%BE%D0%BB.html

 

When there is no combination for this product I can see the specific price in Front Office BUT when I add any combination in back office after that the specific price in Front Office is not vissible

 

Any idea?

Edited by diyan1234 (see edit history)
Link to comment
Share on other sites

  • 7 months later...

Hello everyone,

 

I know this is an old post, but because it's related, I'm posting my new question here.

 

I ran into a problem when testing discounts in my shop (prestashop 1.7). I get the following errors:

 

1 when creating a specific price rule for a product: 'An error occurred while updating the specific price.'

2 When adding a new catalog price rule:

A The first rule provokes no error, but gets ID 0, doesn't show in FO, and when I try to remove it:

  • 'Object cannot be loaded (identifier missing or invalid)' (the translation tool reveals it is an error from the auto upgrade module)
  • 'An error occurred while deleting the object. specific_price_rule (cannot load object)'

B The second rule: 'An error occurred while creating an object. specific_price_rule (Duplicate entry '0' for key 'PRIMARY')'

 

I am currently using:

Prestashop 1.7.2.0

 

Can anyone help me?

 

Thnx, Karin

Link to comment
Share on other sites

  • 1 year later...
On 11/19/2017 at 10:31 PM, karin_aeris said:

Hello everyone,

 

I know this is an old post, but because it's related, I'm posting my new question here.

 

I ran into a problem when testing discounts in my shop (prestashop 1.7). I get the following errors:

 

1 when creating a specific price rule for a product: 'An error occurred while updating the specific price.'

2 When adding a new catalog price rule:

A The first rule provokes no error, but gets ID 0, doesn't show in FO, and when I try to remove it:

  • 'Object cannot be loaded (identifier missing or invalid)' (the translation tool reveals it is an error from the auto upgrade module)
  • 'An error occurred while deleting the object. specific_price_rule (cannot load object)'

B The second rule: 'An error occurred while creating an object. specific_price_rule (Duplicate entry '0' for key 'PRIMARY')'

 

I am currently using:

Prestashop 1.7.2.0

 

Can anyone help me?

 

Thnx, Karin

Hi,

I fixed this issue by making the 'id_specific_price' filed auto increment.

 

ALTER TABLE `ps_specific_price` CHANGE `id_specific_price`
`id_specific_price` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT;

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...