Error_Occurred V3.1.0

Hi all,

Could someone please help me?

I am using V3.1.0 - Site is www.tacklebay.com.au

I get an “Error_Occurred” message whenever I try to view a product on my site.

The main problem is that I can reload a previous backup and it works OK but when I reload the most recent backup the error occurs. I have 50 products loaded since the backup that works and am hoping to solve the problem and save reinstalling all the products again.

As I only recently installed the products I know they were ok as I previewed each one as I went olong. I installed another product yesterday and the error message ocurred and I don't know what to do to get rid of it. below is a copy of the readout I get in development mode.

Hoping someone has a solution.

Thanks Wayne





[size=2][color=#000000][font=Courier]Database error:[/font][/color] Unknown column 'inventory.amount' in 'where clause' b[/b]

[color=#000000][font=Courier]Invalid query:[/font][/color] SELECT MIN(cscart_product_prices.price) min, MAX(cscart_product_prices.price) max FROM cscart_product_prices LEFT JOIN cscart_products ON cscart_products.product_id = cscart_product_prices.product_id LEFT JOIN cscart_product_prices as prices_2 ON cscart_product_prices.product_id = prices_2.product_id AND cscart_product_prices.price > prices_2.price AND prices_2.lower_limit = 1 AND prices_2.usergroup_id IN (0, 0, 1) INNER JOIN cscart_products_categories ON cscart_products_categories.product_id = cscart_products.product_id LEFT JOIN cscart_categories ON cscart_categories.category_id = cscart_products_categories.category_id LEFT JOIN cscart_companies as companies ON companies.company_id = cscart_products.company_id WHERE cscart_products.status IN ('A') AND cscart_products_categories.category_id IN (328) AND (cscart_categories.usergroup_ids = '' OR FIND_IN_SET(0, cscart_categories.usergroup_ids) OR FIND_IN_SET(1, cscart_categories.usergroup_ids)) AND (cscart_products.usergroup_ids = '' OR FIND_IN_SET(0, cscart_products.usergroup_ids) OR FIND_IN_SET(1, cscart_products.usergroup_ids)) AND cscart_categories.status IN ('A', 'H') AND cscart_products.status IN ('A') AND (companies.status = 'A' OR cscart_products.company_id = 0) AND IF(cscart_products.tracking = 'O', inventory.amount > 0, cscart_products.amount > 0) AND cscart_product_prices.lower_limit = 1 AND cscart_product_prices.usergroup_id IN (0, 0, 1) AND prices_2.price IS NULL[/size]

[size=2][color=#000000][font=Courier]Backtrace:[/font][/color][/size] [size=2]File:[/size] [size=2]/home/tackleba/public_html/core/fn.database.php[/size] [size=2]Line:[/size] [size=2]268[/size] [size=2]Function:[/size] [size=2]db_error[/size] [size=2]File:[/size] [size=2]/home/tackleba/public_html/core/fn.database.php[/size] [size=2]Line:[/size] [size=2]78[/size] [size=2]Function:[/size] [size=2]db_query[/size] [size=2]File:[/size] [size=2]/home/tackleba/public_html/core/fn.catalog.php[/size] [size=2]Line:[/size] [size=2]4383[/size] [size=2]Function:[/size] [size=2]db_get_row[/size] [size=2]File:[/size] [size=2]/home/tackleba/public_html/core/classes/bm/block.php[/size] [size=2]Line:[/size] [size=2]733[/size] [size=2]Function:[/size] [size=2]fn_get_filters_products_count[/size] [size=2]File:[/size] [size=2]/home/tackleba/public_html/core/classes/bm/render_manager.php[/size] [size=2]Line:[/size] [size=2]425[/size] [size=2]Function:[/size] [size=2]get_items[/size] [size=2]File:[/size] [size=2]/home/tackleba/public_html/core/classes/bm/render_manager.php[/size] [size=2]Line:[/size] [size=2]312[/size] [size=2]Function:[/size] [size=2]get_value[/size] [size=2]File:[/size] [size=2]/home/tackleba/public_html/core/classes/bm/render_manager.php[/size] [size=2]Line:[/size] [size=2]249[/size] [size=2]Function:[/size] [size=2]render_block_content[/size] [size=2]File:[/size] [size=2]/home/tackleba/public_html/core/classes/bm/render_manager.php[/size] [size=2]Line:[/size] [size=2]199[/size] [size=2]Function:[/size] [size=2]render_block[/size] [size=2]File:[/size] [size=2]/home/tackleba/public_html/core/classes/bm/render_manager.php[/size] [size=2]Line:[/size] [size=2]172[/size] [size=2]Function:[/size] [size=2]render_blocks[/size] [size=2]File:[/size] [size=2]/home/tackleba/public_html/core/classes/bm/render_manager.php[/size] [size=2]Line:[/size] [size=2]148[/size] [size=2]Function:[/size] [size=2]_render_grid[/size] [size=2]File:[/size] [size=2]/home/tackleba/public_html/core/classes/bm/render_manager.php[/size] [size=2]Line:[/size] [size=2]120[/size] [size=2]Function:[/size] [size=2]_render_container[/size] [size=2]File:[/size] [size=2]/home/tackleba/public_html/core/smarty_plugins/function.render_location.php[/size] [size=2]Line:[/size] [size=2]41[/size] [size=2]Function:[/size] [size=2]render[/size] [size=2]File:[/size] [size=2]/home/tackleba/public_html/var/compiled/customer/%%45^45E^45E480CD%%index.tpl.php[/size] [size=2]Line:[/size] [size=2]444[/size] [size=2]Function:[/size] [size=2]smarty_function_render_location[/size] [size=2]File:[/size] [size=2]/home/tackleba/public_html/lib/smarty/Smarty.class.php[/size] [size=2]Line:[/size] [size=2]1265[/size] [size=2]Function:[/size] [size=2]include[/size] [size=2]File:[/size] [size=2]/home/tackleba/public_html/lib/smarty/Smarty.class.php[/size] [size=2]Line:[/size] [size=2]1108[/size] [size=2]Function:[/size] [size=2]fetch[/size] [size=2]File:[/size] [size=2]/home/tackleba/public_html/core/classes/smarty_engine/core.php[/size] [size=2]Line:[/size] [size=2]165[/size] [size=2]Function:[/size] [size=2]display[/size] [size=2]File:[/size] [size=2]/home/tackleba/public_html/core/fn.control.php[/size] [size=2]Line:[/size] [size=2]561[/size] [size=2]Function:[/size] [size=2]display[/size] [size=2]File:[/size] [size=2]/home/tackleba/public_html/index.php[/size] [size=2]Line:[/size] [size=2]22[/size] [size=2]Function:[/size] [size=2]fn_dispatch[/size]

Hi,

I solved my problem of installing the products however the Error is still a puzzle.

I restored the backup that was showing the error, then exported the products to my local.

I then restored the backup that was missing the products and imported the products into that and now it seems to work OK.

I hope this makes sense and that it helps.

Wayne.

Hello Wayne01!



Thank you for all your messages.



Unfortunately, this problem is caused by a well-known bug in CS-Cart version 3.0.1. To fix this issue please replace this part of code:



} elseif (PRODUCT_TYPE == 'ULTIMATE' && $field['field_type'] == 'P' && defined('COMPANY_ID')) {
$db_field = "IF(shared_prices.product_id IS NOT NULL, shared_prices.price, ?:product_prices.price)";
$fields_join .= db_quote("LEFT JOIN ?:ult_product_prices AS shared_prices ON shared_prices.product_id = ?:products.product_id"
. " AND shared_prices.lower_limit = 1"

. " AND shared_prices.usergroup_id IN (?n)"
. " AND shared_prices.company_id = ?i",
array_merge(array(USERGROUP_ALL), $_SESSION['auth']['usergroup_ids']),
COMPANY_ID
);
} else {
$db_field = "?:$field[table].$field[db_field]";


with this one:


} else {
$db_field = "?:$field[table].$field[db_field]";
$fields_join .= $inventory_join;

/* Version:[ULTIMATE] */

if (PRODUCT_TYPE == 'ULTIMATE' && $field['field_type'] == 'P' && defined('COMPANY_ID')) {

$db_field = "IF(shared_prices.product_id IS NOT NULL, shared_prices.price, ?:product_prices.price)";
$fields_join .= db_quote(" LEFT JOIN ?:ult_product_prices AS shared_prices ON shared_prices.product_id = ?:products.product_id"
. " AND shared_prices.lower_limit = 1"
. " AND shared_prices.usergroup_id IN (?n)"
. " AND shared_prices.company_id = ?i",
array_merge(array(USERGROUP_ALL), $_SESSION['auth']['usergroup_ids']),
COMPANY_ID
);
}
/* /Version */




in the fn.catalog.php file located in the core directory of your CS-Cart installation.





Anastasiya Kozlova

CS-Cart Support team

When I try to view the products in admin area for “all stores” in CS-ultimate I get the message “error_occured”.



Debugging sais:



[color=#000000][font=Courier][size=3]Database error:[/size][/font][/color] Not unique table/alias: 'products_categories' b[/b]

[color=#000000][font=Courier][size=3]Invalid query:[/size][/font][/color] SELECT SQL_CALC_FOUND_ROWS products.product_id, products.product_code, products.product_type, products.status, products.company_id, products.list_price, products.amount, products.weight, products.tracking, products.is_edp, descr1.product as product, MIN(IF(prices.percentage_discount = 0, prices.price, prices.price - (prices.price * prices.percentage_discount)/100)) as price, companies.company as company_name, IF(COUNT(IF(cscart_categories.company_id = products.company_id, NULL, cscart_categories.company_id)), 'Y', 'N') as is_shared_product, cscart_seo_names.name as seo_name FROM cscart_products as products LEFT JOIN cscart_product_descriptions as descr1 ON descr1.product_id = products.product_id AND descr1.lang_code = 'EN' LEFT JOIN cscart_product_prices as prices ON prices.product_id = products.product_id AND prices.lower_limit = 1 LEFT JOIN cscart_companies AS companies ON companies.company_id = products.company_id INNER JOIN cscart_products_categories as products_categories ON products_categories.product_id = products.product_id INNER JOIN cscart_categories ON cscart_categories.category_id = products_categories.category_id LEFT JOIN cscart_seo_names ON cscart_seo_names.object_id = products.product_id AND cscart_seo_names.type = 'p' AND cscart_seo_names.dispatch = '' AND cscart_seo_names.lang_code = 'EN' INNER JOIN cscart_products_categories as products_categories ON products_categories.product_id = products.product_id INNER JOIN cscart_categories ON cscart_categories.category_id = products_categories.category_id WHERE 1 AND prices.usergroup_id IN (0) GROUP BY products.product_id ORDER BY products_categories.position asc LIMIT 0, 100



[color=#000000][font=Courier][size=3]Backtrace:[/size][/font][/color] File: /cs/core/fn.database.php Line: 268 Function: db_error File: /cs/core/fn.database.php Line: 29 Function: db_query File: /cs/core/fn.catalog.php Line: 6356 Function: db_get_array File: /cs/controllers/admin/products.php Line: 509 Function: fn_get_products File: /cs/core/fn.control.php Line: 623 Function: include File: /cs/core/fn.control.php Line: 444 Function: fn_run_controller File: /cs/admin.php Line: 24 Function: fn_dispatch



I already followed bug instruction of Anastasiya but unfortunatelly with no result.



Did anyone have the some problem. Please help.

Hello chris102,



Thank you for your message.



I am sorry to hear that you experience this problem. Unfortunately, I have failed to reproduce it in standard CS-Cart 3.0.1 Ultimate Edition. In order that we can help you in this matter, we need to examine this issue on your server. Please contact us via Customer Help Desk and provide temporary access to your server by clicking on the Add record link on the Access information page of your Help Desk account so that we could examine the issue.





Anastasiya Kozlova

CS-Cart Support team

I have the same problem.

When viewing product list under “all stores” we get the same error as you: [color=#000000][font=Courier][size=3]Database error:[/size][/font][/color] Not unique table/alias: ‘products_categories’ (1066)



If you look at the mysql query you can see that two JOIN statements are repeated and that is what is causing the problem:

Look for the following statement in the query below:

INNER JOIN cscart_products_categories as products_categories ON products_categories.product_id = products.product_id

INNER JOIN cscart_categories ON cscart_categories.category_id = products_categories.category_id




It is repeated twice and that what is causing the issue.


<br />
SELECT SQL_CALC_FOUND_ROWS<br />
products.product_id,<br />
products.product_code,<br />
products.product_type,<br />
products.status,<br />
products.company_id,<br />
products.list_price,<br />
products.amount,<br />
products.weight,<br />
products.tracking,<br />
products.is_edp,<br />
descr1.product as product,<br />
MIN(IF(prices.percentage_discount = 0, prices.price, prices.price - (prices.price * prices.percentage_discount)/100)) as price,<br />
companies.company as company_name,<br />
IF(COUNT(IF(cscart_categories.company_id = products.company_id, NULL, cscart_categories.company_id)), 'Y', 'N') as is_shared_product<br />
FROM<br />
cscart_products as products<br />
LEFT JOIN cscart_product_descriptions as descr1 ON descr1.product_id = products.product_id AND descr1.lang_code = 'EN'<br />
LEFT JOIN cscart_product_prices as prices ON prices.product_id = products.product_id AND prices.lower_limit = 1<br />
LEFT JOIN cscart_companies AS companies ON companies.company_id = products.company_id<br />
<br />
INNER JOIN cscart_products_categories as products_categories ON products_categories.product_id = products.product_id<br />
INNER JOIN cscart_categories ON cscart_categories.category_id = products_categories.category_id<br />
<br />
INNER JOIN cscart_products_categories as products_categories ON products_categories.product_id = products.product_id<br />
INNER JOIN cscart_categories ON cscart_categories.category_id = products_categories.category_id<br />
<br />
WHERE 1 AND prices.usergroup_id IN (0)<br />
GROUP BY products.product_id<br />
ORDER BY products_categories.position asc<br />
LIMIT 0, 10<br />

```<br />
<br />
Look at:<br />
core/fn.catalog.php around line 6624<br />
```php
<br />
	if (in_array('sharing', $params['extend'])) {<br />
		$fields[] = "IF(COUNT(IF(?:categories.company_id = products.company_id, NULL, ?:categories.company_id)), 'Y', 'N') as is_shared_product";<br />
		if (strpos($join, $categories_join) === false) {<br />
			$join .= $categories_join;<br />
		}<br />
	}<br />

```<br />
<br />
and comment the following line: $join .= $categories_join;<br />
as follows:<br />
```php
<br />
	if (in_array('sharing', $params['extend'])) {<br />
		$fields[] = "IF(COUNT(IF(?:categories.company_id = products.company_id, NULL, ?:categories.company_id)), 'Y', 'N') as is_shared_product";<br />
		if (strpos($join, $categories_join) === false) {<br />
		//	$join .= $categories_join;<br />
		}<br />
	}<br />

```<br />
<br />
After doing that everything works as expected.<br />
I'm sure it is a bug and I have no idea if by commenting this line I'm affecting something else but it should be up to CS-CART guys and girls <img src="upload://ssa1U17ndImgNZSdwFNmOF2yUgM.png" class="bbc_emoticon" alt=";)"> to sort this out correctly.

More than likely, there is an addon you have configured that has a hook for 'get_products' that is duplicating part of the query.

My guess is that if you ever find the addon that is the culprit, that if it ever becomes disabled that you will loose data being displayed on your product pages (or listing pages).



More than likely it's a 3rd party addon. If you have SSH access, you can find which addons use that hook via:

find addons -name 'init.php' -print | xargs grep 'get_products'


This will give you a listing (or at least close) of all addons that use the 'get_products' hook. However, this could be many and you might want to just identify what 3rd party addons you have installed.


addons/product_configurator/init.php: 'get_products',
addons/product_configurator/init.php: 'get_products_post',
addons/bestsellers/init.php: 'get_products_pre',
addons/bestsellers/init.php: 'get_products',
addons/recurring_billing/init.php: 'get_products',
addons/affiliate/init.php: 'get_products_pre',
addons/affiliate/init.php: 'get_products',
addons/searchanise/init.php: 'get_products_before_select',
addons/required_products/init.php: 'get_products',
addons/age_verification/init.php: 'get_products',
addons/twigmo/init.php: 'get_products',
addons/seo/init.php: 'get_products',
addons/seo/init.php: 'get_products_post',
addons/customers_also_bought/init.php: 'get_products'
addons/discussion/init.php: 'get_products',
addons/tags/init.php: 'get_products',




Above is list of all addons I have that use 'get_products'.

Some of them we don't use at all some of them we do.

I went through the whole list and disabled one by one, than tried to view products for 'all stores' in admin.

With the mod I described above I could view all products just fine. Disabling any or all of the above addons made no difference.

We do not use (at the moment) any 3-rd party addons at all. All the addons we use currently are the ones that came with cs-cart ultimate 3.0.3

So it still looks like a bug in the core of cs-cart?

Given you are running 3.0.1 (the first release of V3), good bet the problem was in the core cart and that it has probably been corrected. Though I'm surprised no one else has brought it up from then…

[quote name='tbirnseth' timestamp='1349212179' post='146214']

Given you are running 3.0.1 (the first release of V3), good bet the problem was in the core cart and that it has probably been corrected. Though I'm surprised no one else has brought it up from then…

[/quote]



I'm actually running 3.0.3



…taken from config.php:


// Product information
define('PRODUCT_NAME', 'CS-Cart');
define('PRODUCT_VERSION', '3.0.3');
define('PRODUCT_STATUS', '');
define('PRODUCT_BUILD', '');

Your original post said 3.0.1 so that's what I was going by.

I would invest in a helpdesk ticket to find out what the problem is. If it's a bug, there'll be no cost. If it's something on your end, they will identify or address it for you.



But I certainly wouldn't comment out a chunk of core code for other than a temporary solution.

[quote name=‘tbirnseth’ timestamp=‘1349287646’ post=‘146277’]

Your original post said 3.0.1 so that’s what I was going by.

[/quote]



Actually the original poster was Wayne01 ;)

I simply came across his post when trying to research identical problem with my installation.



I agree with you, a bug report will have to be made to get this sorted.

Thank you for all your help.



raff