Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Database Table Question: cscart_new_orders Rate Topic   * * * * * 1 votes

 
  • solesurvivor
  • Senior Member
  • Members
  • Join Date: 05-Aug 11
  • 745 posts

Posted 17 August 2012 - 05:14 PM #1

Does anyone have any idea what the purpose of cscart_new_orders table is? Why does it exist? I can't figure out what its being used for to know if i should be utilizing it in my order import addons.

 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11248 posts

Posted 18 August 2012 - 07:53 PM #2

It appears to be for twigmo. I think it has to do with who has rights to view an order but not sure.

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • Magpie Don
  • Senior Member
  • Members
  • Join Date: 01-Apr 09
  • 811 posts

Posted 12 September 2012 - 06:00 PM #3

The data in this table is obnoxious.
Each new order_id is listed 1000 times - once for each customer_id. It currently has over 75,000 rows in it for 75 order numbers.
I'm backing it up, truncating it and testing.
If it's for Twigmo - I disabled Twigmo a month ago. If it controls rights - it's broken anyway.

CS-Cart Ultimate ver 4.3.5


 
  • solesurvivor
  • Senior Member
  • Members
  • Join Date: 05-Aug 11
  • 745 posts

Posted 12 September 2012 - 06:31 PM #4

Wow yeah mine has 956k records. Anyone else have any clue if I can truncate it safely?

 
  • clips
  • Aged Resident Loon
  • Members
  • Join Date: 14-Jan 07
  • 1650 posts

Posted 15 September 2012 - 03:57 AM #5

Ran in to some problems with our database and was reviewing the tables. This one is 165k on ours. The funny part is I only turned on twigmo for a few hours before I realized how much I hated it. Has anyone truncate or emptied the file yet?
Regards,
Jim

 
  • solesurvivor
  • Senior Member
  • Members
  • Join Date: 05-Aug 11
  • 745 posts

Posted 15 September 2012 - 04:36 AM #6

We have never used twigmo so that table must be for something else.

 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11248 posts

Posted 15 September 2012 - 04:48 AM #7

From a quick review of fn.cart.php it appears that it has to do with tracking of orders or otherwise relating an order to an admin user_id.

It appears that when an order is created that a record for every (current) admin user_id is inserted (one line per admin per order).
From what I can see, twigmo is the only "consumer" of this info. Sad thing is that since the only consumer is an addon, it should be done with a hook, not directly integrated into the fn.cart.php file. But then they tend to do that to make their addon development easier.

If you don't use twigmo, you can probably comment out the code in fn.cart.php and truncate the table.

					    //
					    // Place the order_id to new_orders table for all admin profiles
					    //
					    if (!$parent_order_id) {
							    $condition = '';
							    if (PRODUCT_TYPE == 'MULTIVENDOR') {
									    $condition = empty($order['company_id']) ? ' AND company_id = 0 ' : fn_get_company_condition('company_id', true, $order['company_id'], true);
							    }
							    $admins = db_get_fields("SELECT user_id FROM ?:users WHERE user_type = 'A' $condition");
							    foreach ($admins as $k => $v) {
									    db_query("REPLACE INTO ?:new_orders (order_id, user_id) VALUES (?i, ?i)", $order_id, $v);
							    }
					    }

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • solesurvivor
  • Senior Member
  • Members
  • Join Date: 05-Aug 11
  • 745 posts

Posted 15 September 2012 - 05:25 AM #8

Thanks for all that info ill be taking a look at it further.

 
  • clips
  • Aged Resident Loon
  • Members
  • Join Date: 14-Jan 07
  • 1650 posts

Posted 15 September 2012 - 02:05 PM #9

Has anyone actually cleared out this file?
Regards,
Jim

 
  • Magpie Don
  • Senior Member
  • Members
  • Join Date: 01-Apr 09
  • 811 posts

Posted 15 September 2012 - 06:33 PM #10

I did. I truncated the table last week.
For each new order, the fn.cart.php script still inserts a row for each user (not just for each admin user). Truncating (emptying) the table had zero impact on the store's front end and/or back end.
I can find no reason for the table at all for function in the store proper. I do agree with tbirnseth though, the logic does appear to be for WHICH Twigmo users have access to the order, but I only have one admin user, so it's either got a bug, or Twigmo uses this table to give ALL users access to ALL orders - and that doesn't make any sense.

I'm reporting this in the Bug Tracker.

I have Twigmo disabled.

CS-Cart Ultimate ver 4.3.5


 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11248 posts

Posted 15 September 2012 - 07:02 PM #11

Should only be admin users (or users with user_type == 'A') according to the code.

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • Magpie Don
  • Senior Member
  • Members
  • Join Date: 01-Apr 09
  • 811 posts

Posted 15 September 2012 - 11:55 PM #12

My fn.cart.php script for ver3.0.3 is different. The where clause is missing (unless you are using the MultiVendor edition.)

// Place the order_id to new_orders table for all admin profiles
   //
   if (!$parent_order_id) {
    $condition = '';
    if (PRODUCT_TYPE == 'MULTIVENDOR') {
	 $condition = empty($order['company_id']) ? "AND user_type = 'A' AND company_id = 0 " : "AND user_type = 'V' " . fn_get_company_condition('?:users.company_id', true, $order['company_id'], true);
    }
    $admins = db_get_fields("SELECT user_id FROM ?:users WHERE 1 $condition");
    foreach ($admins as $k => $v) {
	 db_query("REPLACE INTO ?:new_orders (order_id, user_id) VALUES (?i, ?i)", $order_id, $v);
    }

CS-Cart Ultimate ver 4.3.5


 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11248 posts

Posted 16 September 2012 - 01:03 AM #13

yeah, I was referencing 2.2.4 so that would be a bug in my opinion.... And that would make that table get really big, really fast for a mature store and if you "combined customers" in Ultimate, it could make it get even bigger..

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • tmv
  • Member
  • Members
  • Join Date: 14-Sep 07
  • 148 posts

Posted 25 September 2012 - 08:12 AM #14

Mine has about 600,000 strings! (the whole database has about 1,000,00 strings) and about 11 Mb :-). I have just truncated it - now I am waiting what will happen :-)

 
  • Magpie Don
  • Senior Member
  • Members
  • Join Date: 01-Apr 09
  • 811 posts

Posted 25 September 2012 - 04:41 PM #15

Fixed in next version.
See the fix in Bug Tracker:
http://forum.cs-cart...rder-table-bug/

CS-Cart Ultimate ver 4.3.5


 
  • clips
  • Aged Resident Loon
  • Members
  • Join Date: 14-Jan 07
  • 1650 posts

Posted 25 September 2012 - 05:58 PM #16

That link refers to version 3. It needs to be fixed in version 2! I'm not for sure about anyone else, but it may be some time before I upgrade to version 3...if I do at all. Not only do I want to mess with all the bugs in version 3, but I need to know which direction CS-Cart is going on the "1 version covers all" issue before I spend the time upgrading.
Regards,
Jim

 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11248 posts

Posted 26 September 2012 - 01:25 AM #17

Jim, have you tried just commenting out the code block? I believe it is only used by twigmo...
References to ":new_orders" in V2.2.4 are only:
./addons/twigmo/func.php:			   $condition .= db_quote(" AND ?:new_orders.user_id = ?i", $params['admin_user_id']);
./addons/twigmo/func.php:			   $join .= " LEFT JOIN ?:new_orders ON ?:new_orders.order_id = ?:orders.order_id";
./core/fn.cart.php:									 db_query("REPLACE INTO ?:new_orders (order_id, user_id) VALUES (?i, ?i)", $order_id, $v);
./core/fn.cart.php:	 db_query("DELETE FROM ?:new_orders WHERE order_id = ?i", $order_id);
./core/fn.cart.php:			 $condition .= db_quote(" AND ?:new_orders.user_id = ?i", $params['admin_user_id']);
./core/fn.cart.php:			 $join .= " LEFT JOIN ?:new_orders ON ?:new_orders.order_id = ?:orders.order_id";
./controllers/admin/orders.php: db_query("DELETE FROM ?:new_orders WHERE order_id = ?i AND user_id = ?i", $_REQUEST['order_id'], $auth['user_id']);

Sure looks to me like twigmo is the only one that uses the data. If so, it shouldn't be hard-wired into the standard cart since twiggy is an addon.

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • ghsc
  • Junior Member
  • Members
  • Join Date: 03-Aug 07
  • 53 posts

Posted 26 April 2013 - 11:16 AM #18

my
cscart_new_order

is about 600MB after a few days. using twigmo.

my total database is 700MB.....