Guest sheik Posted December 13, 2012 Share Posted December 13, 2012 The Assign to Category tab has always been slow for us but now we have 9000+ products it actually hangs the browser. The error in Firefox is: A script on this page may be busy, or it may have stopped responding. You can stop the script now, or you can continue to see if the script will complete. Script: https://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js:3 Performance is similarly bad in IE and Chrome. Given we need to add several thousand more products soon, and these all need assigning to multiple subcategories, can anybody suggest a fix or workaround please? Thank you, /\dam Quote Link to comment Share on other sites More sharing options...
Guest sheik Posted December 13, 2012 Share Posted December 13, 2012 I have fixed this by editing /admin/sources/products.assign.inc.php Basically, I have added the missing "where" clause to the product list SQL. So, I can now go to my inventory, filter by a category and then when I click "assign to category" my filter is still in place and jquery doesn't hang trying to display 9000+ products. This is only a few lines of code and makes this feature much more responsive and easy to use, so should probably go in the next version of CubeCart - how do I send a patch through? /damHere is the code I used in /admin/sources/products.assign.inc.php, approx line 66, in case it is helpful to anyone else: ## Product list // /dam hack to filter by category, this is copy / pasted from products.index.inc.php and contains redundant checks, // but I've left them in for completeness in case somebody wants to add support for the alphabetic filter as well if (isset($_GET['cat_id']) && is_numeric($_GET['cat_id'])) { if (!$where) { $where = ''; } else { $where .= ' AND '; } // We got a category - $where is certainly not false anymore. if (($cat_products = $GLOBALS['db']->select('CubeCart_category_index', array('product_id'), array('cat_id' => (int)$_GET['cat_id']))) !== false) { $where .= '(product_id IN ('; foreach ($cat_products as $prod) { $where .= $prod['product_id'].','; } $where = substr($where, 0, -1); $where .= ') OR cat_id = '.(int)$_GET['cat_id'].')'; } } // add the new where clause that we generated above - /dam if (($products = $GLOBALS['db']->select('CubeCart_inventory', array('product_id', 'name', 'product_code'), $where, array('name' => 'ASC'))) !== false) { // old code below commented out to show what has changed - /dam //if (($products = $GLOBALS['db']->select('CubeCart_inventory', array('product_id', 'name', 'product_code'), false, array('name' => 'ASC'))) !== false) { $GLOBALS['smarty']->assign('PRODUCTS',$products); } // end of amend to filter by category - /dam Quote Link to comment Share on other sites More sharing options...
bsmither Posted December 13, 2012 Share Posted December 13, 2012 An interesting hack. What I would like, if you are amenable to do this, restore the above file to its original coding, then, in /js/common.html, change the version of the jQuery file from /jquery.min.js to /jquery.js. Line 3 of the minified version is actually lines 2879-5866 of the non-minified version. I would very much like to know what Firefox reports on this non-minified version as to what actual routine is taking too long to process and what it is processing. You are only one of a very few individuals who have a multi-thousand product inventory. Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted December 13, 2012 Share Posted December 13, 2012 I have 3000+ inventory now in our plush store, with many more to be added. So I would like to see this working in a future version. Glad to see it's being addressed here. Thanks!!A Quote Link to comment Share on other sites More sharing options...
Guest sheik Posted December 14, 2012 Share Posted December 14, 2012 An interesting hack. What I would like, if you are amenable to do this, restore the above file to its original coding, then, in /js/common.html, change the version of the jQuery file from /jquery.min.js to /jquery.js. Line 3 of the minified version is actually lines 2879-5866 of the non-minified version. I would very much like to know what Firefox reports on this non-minified version as to what actual routine is taking too long to process and what it is processing. I have made this change, but to affect admin I had to modify /admin/skins/default/template/main.php instead. The scripts hung in Firefox twice upon clicking the Assign to Categories tab, here are the messages (for both I clicked "continue" and the page eventually loaded correctly, after approx 30 seconds) Script: https://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js:4122 Script: https://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js:5437 Is that helpful? Even if the problem can be optimised in the JS, I still think my proposed change makes sense. In my experience, if a user clicks "Assign to Category" they will not always need to see an entire product list, so it is very handy to be able to filter by category. /dam Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.