Jump to content

Stock Levels Updated From an API - Cache Problems


disco_ii_disco

Recommended Posts

All SQL queries that contain stock_level information, both in the Cubecart tables and the custom table, are not cached (as confirmed by the debug section).

16.	Hack: 1626816962.30120 --- Duration: 264 µs [NOT CACHED]
SELECT `stock_level`, `product_code`, `upc`, `jan`, `isbn`, `image` FROM `CubeCart_option_matrix` WHERE CubeCart_option_matrix.product_id = '1008' AND CubeCart_option_matrix.options_identifier IS NULL AND CubeCart_option_matrix.status = '1' ;

21.	Hack: 1626816962.30170 --- Duration: 176 µs [NOT CACHED]
SELECT `stock_level`, `product_code`, `upc`, `jan`, `isbn`, `image` FROM `CubeCart_option_matrix` WHERE CubeCart_option_matrix.product_id = '1008' AND CubeCart_option_matrix.options_identifier IS NULL AND CubeCart_option_matrix.status = '1' ;

24.	Hack: 1626816962.30250 --- Duration: 282 µs [NOT CACHED]
SELECT SQL_CALC_FOUND_ROWS MAX(stock_level) AS `stock_level` FROM `CubeCart_option_matrix` WHERE CubeCart_option_matrix.product_id = '1008' AND CubeCart_option_matrix.status = '1' AND CubeCart_option_matrix.use_stock = '1' LIMIT 1;

25.	Hack: 1626816962.30280 --- Duration: 206 µs [NOT CACHED]
SELECT SQL_CALC_FOUND_ROWS `stock_level` FROM `CubeCart_inventory` WHERE CubeCart_inventory.product_id = '1008' LIMIT 1;

75.	Hack: 1626816962.30830 --- Duration: 499 µs [NOT CACHED]
SELECT `stock_level` FROM `stock_levels` WHERE stock_levels.product_id = '1008' AND stock_levels.location_id = '1' ORDER BY location_id ;

131.	Hack: 1626816962.34640 --- Duration: 567 µs [NOT CACHED]
SELECT SQL_CALC_FOUND_ROWS `stock_level` FROM `CubeCart_inventory` WHERE CubeCart_inventory.product_id = '7552' LIMIT 1;

 

Link to comment
Share on other sites

A few messages back, we used $GLOBALS['debug']->debugMessage() at key places just before the values were assigned to the template variables.

I would next place these statements all over the code snippet looking for any anomalies or differences.

$GLOBALS['debug']->debugMessage("At line ".__LINE__.", the stock_status is: ".($stock_status?"True":"False"));

$GLOBALS['debug']->debugMessage("At line ".__LINE__.", the stock_level is: ".$stock_level);

Put an appropriate version after each and every statement that gets or changes something.

Get a page view. Change the value but do not clear the cache. Get another page view. Compare the debug messages.

Link to comment
Share on other sites

Another great tip. A line of code which I will use a lot, going forward.

I inserted the debug code and there is no change in the stock_level at the beginning, middle or end of my code snippet. It is always showing the out of date stock level. Therefore, the problem is before it gets to the code snippet.

The below example had been updated, via the API, to show a stock level of 13:

[0] At line 3, the stock_status is: True
[1] At line 5, the stock_level is: 12
[2] The stock_status is: True
[3] The stock_level is: 12
[4] The stock_level_supplier is: 0
[5] The stock_level_shop is: 5
[6] The stock_level_warehouse is: 7
[7] At line 60, the stock_status is: True
[8] At line 62, the stock_level is: 12

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...