jay4linux Posted May 17, 2007 Share Posted May 17, 2007 I currently have 2 store, one custom written about 10 years ago. And one is outsourced to a different company. We want to move both stores in house. The difference between the 2 stores is that you have to be a privileged user to order from one of them, ie the products are not available to the general public. Can I run one OSCommerce site and hide certain products based on their login username? Or will I have to run 2 separate stores? Thanks, Jay National Beta Club Link to comment Share on other sites More sharing options...
Jan Zonjee Posted May 17, 2007 Share Posted May 17, 2007 Can I run one OSCommerce site and hide certain products based on their login username? Or will I have to run 2 separate stores? There is a search function in the Contributions. Using "hide products" would have given two pages of results of which I know Hide products from customer groups for SPPC would do that. It is quite a bit of work to install, because you first need to install SPPC but there lots of places where you need to hide a product (or complete category) :) Link to comment Share on other sites More sharing options...
Guest Posted May 19, 2007 Share Posted May 19, 2007 There is a search function in the Contributions. Using "hide products" would have given two pages of results of which I know Hide products from customer groups for SPPC would do that. It is quite a bit of work to install, because you first need to install SPPC but there lots of places where you need to hide a product (or complete category) :) Hi Janz I wonder if I could hide a top-level category. At the moment, I have 4 categories on the top level. I disable 2 of them, but they still appear together with the other two. Although the users cannot see any sub-categories or products of the disabled categories, I still want to hide the two on the index page, i.e. the front page of the shop. I use SPPC, Hide from groups, Price Break, ...(most are from your contributions), ....and others. Cheers James Link to comment Share on other sites More sharing options...
Jan Zonjee Posted May 19, 2007 Share Posted May 19, 2007 I wonder if I could hide a top-level category. At the moment, I have 4 categories on the top level. I disable 2 of them, but they still appear together with the other two. That's weird. If you disable them in the admin they shouldn't show up in the categories box. Unless there is something special/diffferent in that box which isn't modified for the hide categories thing. Link to comment Share on other sites More sharing options...
Guest Posted May 20, 2007 Share Posted May 20, 2007 That's weird. If you disable them in the admin they shouldn't show up in the categories box. Unless there is something special/diffferent in that box which isn't modified for the hide categories thing. Hi JanZ Here belows are the two files I found something strange, do you have time looking into them: 1. catalog/includes/boxes/categories.php 2. catalog/includes/boxes/categories.php (Tried to modify before, but in vain) I remembered I have done something to the second file, but when I tried to load the file, it seems not working. That's why I restored the first file, and in current, I use the 1st file in the working website. This might explain why the category on the top level is not hidden now, but only the subcategory and the products are hidden. I hope you could help me diagnose the problem or perhaps it's just simply one or two mis-statements. Many thanks. James Link to comment Share on other sites More sharing options...
Guest Posted May 20, 2007 Share Posted May 20, 2007 Hi JanZ Here belows are the two files I found something strange, do you have time looking into them: 1. catalog/includes/boxes/categories.php 2. catalog/includes/boxes/categories.php (Tried to modify before, but in vain) I remembered I have done something to the second file, but when I tried to load the file, it seems not working. That's why I restored the first file, and in current, I use the 1st file in the working website. This might explain why the category on the top level is not hidden now, but only the subcategory and the products are hidden. I hope you could help me diagnose the problem or perhaps it's just simply one or two mis-statements. Many thanks. James Also, JanZ Would it be related to either one of the files: 1. catalog/includes/application_top.php, or 2. catalog/index.php I hope the problem should come from either one of the 4 files. Shouldn't it? James Link to comment Share on other sites More sharing options...
Jan Zonjee Posted May 20, 2007 Share Posted May 20, 2007 James, I remembered I have done something to the second file, but when I tried to load the file, it seems not working. That's why I restored the first file, and in current, I use the 1st file in the working website. This might explain why the category on the top level is not hidden now, but only the subcategory and the products are hidden. So you knew very well that it was something with your own code instead of the contribution :) Try these changes to your current /boxes/categories.php first: around line 15 change to: function build_menus($currentParID,$menustr,$catstr, $indent) { global $categories_string, $id, $languages_id; // BOF Separate Pricing Per Customer, hide products and categories from groups if (isset($_SESSION['sppc_customer_group_id']) && $_SESSION['sppc_customer_group_id'] != '0') { $customer_group_id = $_SESSION['sppc_customer_group_id']; } else { $customer_group_id = '0'; } $tmpCount; $tmpCount = 0; $haschildren = 0; //default $categories_query_catmenu = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . $currentParID . "' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' and find_in_set('" . $customer_group_id . "', categories_hide_from_groups) = 0 order by sort_order, cd.categories_name"); // EOF Separate Pricing Per Customer, hide products and categories from groups and then around (now) line 96: $currentCPath = $HTTP_GET_VARS['cPath']; if (! isset($currentCPath)) { if (isset($HTTP_GET_VARS['products_id'])) { // BOF Separate Pricing Per Customer, hide products and categories from groups global $customer_group_id; // this should work, otherwise add the if/else for the customer group above here again $cPathQuery = tep_db_query("select c.categories_id, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, products p where p2c.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and c.categories_id = p2c.categories_id and p.products_id = p2c.products_id and find_in_set('" . $customer_group_id . "', categories_hide_from_groups) = 0 and p.products_status = '1' and find_in_set('".$customer_group_id."', products_hide_from_groups) = 0"); // EOF Separate Pricing Per Customer, hide products and categories from groups if ($cp = tep_db_fetch_array($cPathQuery)) { Link to comment Share on other sites More sharing options...
Guest Posted May 20, 2007 Share Posted May 20, 2007 James, So you knew very well that it was something with your own code instead of the contribution :) Try these changes to your current /boxes/categories.php first: around line 15 change to: function build_menus($currentParID,$menustr,$catstr, $indent) { global $categories_string, $id, $languages_id; // BOF Separate Pricing Per Customer, hide products and categories from groups if (isset($_SESSION['sppc_customer_group_id']) && $_SESSION['sppc_customer_group_id'] != '0') { $customer_group_id = $_SESSION['sppc_customer_group_id']; } else { $customer_group_id = '0'; } $tmpCount; $tmpCount = 0; $haschildren = 0; //default $categories_query_catmenu = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . $currentParID . "' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' and find_in_set('" . $customer_group_id . "', categories_hide_from_groups) = 0 order by sort_order, cd.categories_name"); // EOF Separate Pricing Per Customer, hide products and categories from groups and then around (now) line 96: $currentCPath = $HTTP_GET_VARS['cPath']; if (! isset($currentCPath)) { if (isset($HTTP_GET_VARS['products_id'])) { // BOF Separate Pricing Per Customer, hide products and categories from groups global $customer_group_id; // this should work, otherwise add the if/else for the customer group above here again $cPathQuery = tep_db_query("select c.categories_id, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, products p where p2c.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and c.categories_id = p2c.categories_id and p.products_id = p2c.products_id and find_in_set('" . $customer_group_id . "', categories_hide_from_groups) = 0 and p.products_status = '1' and find_in_set('".$customer_group_id."', products_hide_from_groups) = 0"); // EOF Separate Pricing Per Customer, hide products and categories from groups if ($cp = tep_db_fetch_array($cPathQuery)) { Dear JanZ Thanks for your help. I followed your instuctions. Done. What's next? The amendments seem to be from your contributions, "Hide Products and Categories v201" or "Hide products for SPPC". Thanks. Your contribution is always reliable. My own amendments came from "Enable/Disable Category button". There may be also another contribution, the disable category when there is no product. If you remember, last time you help me to disable all the duplicate products that come from different categories, it has been a long time known bugs of installing the "Enable/Disable Category button". This time, I raised the problem of "not able to disable the category on the main page" is also another known bug of the same contribution. So, should I restore all the related files by uninstalling the "Enable/Disable Category button" before installing the "Hide Products and Categories"? But there are two versions, one as 2.01 and the other is for SPPC. Which one should I use? But I can foresee there might be big operations and "long hours" restore and install because I have to edit backward from the installation menu. Actually, the site has been working fine since last time modification helped by you. Now, I just want to let the supplier to modify the product price and data, so I installed the Admin user and the supplier module. However, I could only assign hidden categories on the top level for the supplier to work on their own products. If I keep everything unchanged, I can hide a category in the 2nd level. But the supplier can't work on it. If I hide a category in the top level, the supplier can work on it, but the category is displayed as an empty category on the main page. This is why I have to hide the category on the top level. So, if I keep everything as the current website, what's the next file that I can modify, the index.php? If this is not possible, should I uninstall the "Enable/Disable Category button" as mentioned above? Hope you can give me some advice! Thanks in advance Cheers James Link to comment Share on other sites More sharing options...
Jan Zonjee Posted May 20, 2007 Share Posted May 20, 2007 I followed your instuctions. Done. What's next? The amendments seem to be from your contributions, "Hide Products and Categories v201" or "Hide products for SPPC". Thanks. Your contribution is always reliable. My own amendments came from "Enable/Disable Category button". You didn't mentioned that in your first post: I use SPPC, Hide from groups, Price Break, ...(most are from your contributions), ....and others. Hide products for SPPC started with just being able to hide products. The last version, uploaded under the same contribution number, can also hide categories. Since it offers more possibilities and safeguards than the contribution "Enable/Disable Category" there is no use for the last one. So if you installed hide from groups (the last version) than you simply disable the category in the admin for all groups to get the functionality that "Enable/Disable Category" is (supposed) to give. Link to comment Share on other sites More sharing options...
Guest Posted May 21, 2007 Share Posted May 21, 2007 You didn't mentioned that in your first post: Hide products for SPPC started with just being able to hide products. The last version, uploaded under the same contribution number, can also hide categories. Since it offers more possibilities and safeguards than the contribution "Enable/Disable Category" there is no use for the last one. So if you installed hide from groups (the last version) than you simply disable the category in the admin for all groups to get the functionality that "Enable/Disable Category" is (supposed) to give. JanZ Thanks for your prompt reply. I wonder which version I should install. I install the one for SPPC. But I found one without the SPPC, i.e. version 2.XX. Is that the latest one? For uninstalling the "Disable/Enable..." I think it's quite a mild operation. I hope I can manage. Thanks James Link to comment Share on other sites More sharing options...
Jan Zonjee Posted May 21, 2007 Share Posted May 21, 2007 I wonder which version I should install. I install the one for SPPC. But I found one without the SPPC, i.e. version 2.XX. Is that the latest one? You would need version 2.0.1 of August 6, 2006. That one contains the hiding of categories and is most up-to-date. Link to comment Share on other sites More sharing options...
Jan Zonjee Posted May 21, 2007 Share Posted May 21, 2007 If you remember, last time you help me to disable all the duplicate products that come from different categories Actually, later I found out that another trick might do the same thing, but cleaner. I recall there was trouble adding a "distinct" before products_id. I found that when you call the split_classes file with as second parameter 'products_id' that problem with the count query is not happening. Anyway, I can't really remember where to add that now :) Link to comment Share on other sites More sharing options...
Guest Posted May 22, 2007 Share Posted May 22, 2007 Actually, later I found out that another trick might do the same thing, but cleaner. I recall there was trouble adding a "distinct" before products_id. I found that when you call the split_classes file with as second parameter 'products_id' that problem with the count query is not happening. Anyway, I can't really remember where to add that now :) Thanks JanZ I plan to work on it tonight or tomorrow. At the same time, I am trying to rebuid another oscommerce with only the most useful add-ons. For sure, I would add all your contribution, Let's see : the SPPC, the Quantity Price Break, Hide Products, Multiple Quantity, Best Sellers, Admin Specials, and Tax for SPPC, etc. Then, I will add some others, like now I use buy 2, bundle, extra fields, payment module, shipping modules, who's online, etc. Also an important ones include the Administration Access Level Accounts. But how about Margin Report? I'm not sure if I need this for Suppliers Product Administration Solution? Anyway, I'm sure your contributions are the most useful ones. Many thanks. James Link to comment Share on other sites More sharing options...
Guest Posted May 26, 2007 Share Posted May 26, 2007 You didn't mentioned that in your first post: Hide products for SPPC started with just being able to hide products. The last version, uploaded under the same contribution number, can also hide categories. Since it offers more possibilities and safeguards than the contribution "Enable/Disable Category" there is no use for the last one. So if you installed hide from groups (the last version) than you simply disable the category in the admin for all groups to get the functionality that "Enable/Disable Category" is (supposed) to give. Hi JanZ I finished the uninstallation of "Enabled/Disabled" module. Then I install the latest version of Hide Products and Categories. 2 problems are found now. 1. When I disabled a category on the top level, the icon still show. It is the same as before. Even I hide the category from group 0, ONLY the categories on the top level appear. However, it shows nothing inside that category. 2. When clicking the category or the sub-categories, it take quite a long time to wait for the result to appear. About 2 ~ 3 times longer. I think it might be the files that I have installed and uninstall many times. How could I find out which files explain the above two results? Perhaps, I should replace temporarily my file(s) with your amended files one after the other. After I can streamline the files, perhaps I can include those files for your examination in the next message. At the moment, I finish my report and will get back to you after finishing all the comparison by trial and error. Thank you James Link to comment Share on other sites More sharing options...
Guest Posted May 26, 2007 Share Posted May 26, 2007 Hi JanZ I finished the uninstallation of "Enabled/Disabled" module. Then I install the latest version of Hide Products and Categories. 2 problems are found now. 1. When I disabled a category on the top level, the icon still show. It is the same as before. Even I hide the category from group 0, ONLY the categories on the top level appear. However, it shows nothing inside that category. 2. When clicking the category or the sub-categories, it take quite a long time to wait for the result to appear. About 2 ~ 3 times longer. I think it might be the files that I have installed and uninstall many times. Hi JanZ, The second problem regarding "slow" is due to the catalog/includes/functions/general.php. I have included both files for your reference. 1. The file before upgraded with Hide Products and Categories 2. The file upgraded with Hide Products and Categories I'm still working on the Problem 1 now. Thanks in advance. Cheers James Link to comment Share on other sites More sharing options...
Jan Zonjee Posted May 26, 2007 Share Posted May 26, 2007 The second problem regarding "slow" is due to the catalog/includes/functions/general.php. I have included both files for your The thing that might be the problem is the function tep_count_products_in_category around line 435. You could try to outcomment the new one and add your previous one. Counting products has always been a thing that slowed done the site but perhaps even more now (it is neccesary to add the table categories in the query which makes it a bigger result set so inevitably slower). Link to comment Share on other sites More sharing options...
Guest Posted May 26, 2007 Share Posted May 26, 2007 The thing that might be the problem is the function tep_count_products_in_category around line 435. You could try to outcomment the new one and add your previous one. Counting products has always been a thing that slowed done the site but perhaps even more now (it is neccesary to add the table categories in the query which makes it a bigger result set so inevitably slower). Hi JanZ, Thanks for your quick reply. Here below is your instructions. Now, it is much faster. // BOF Separate Pricing Per Customer, hide products and categories for groups global $sppc_customer_group_id; if(!tep_session_is_registered('sppc_customer_group_id')) { $customer_group_id = '0'; } else { $customer_group_id = $sppc_customer_group_id; } $products_count = 0; if ($include_inactive == true) { $products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = p2c.products_id and p2c.categories_id = '" . (int)$category_id . "' and find_in_set('".$customer_group_id."', products_hide_from_groups) = 0 "); /*$products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_CATEGORIES . " c using(categories_id) where p.products_id = p2c.products_id and p2c.categories_id = '" . (int)$category_id . "' and find_in_set('".$customer_group_id."', products_hide_from_groups) = 0 and find_in_set('" . $customer_group_id . "', categories_hide_from_groups) = 0");*/ } else { /*$products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_CATEGORIES . " c using(categories_id) where p.products_id = p2c.products_id and p.products_status = '1' and p2c.categories_id = '" . (int)$category_id . "' and find_in_set('".$customer_group_id."', products_hide_from_groups) = 0 and find_in_set('" . $customer_group_id . "', categories_hide_from_groups) = 0");*/ $products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = p2c.products_id and p.products_status = '1' and p2c.categories_id = '" . (int)$category_id . "' and find_in_set('".$customer_group_id."', products_hide_from_groups) = 0 "); } $products = tep_db_fetch_array($products_query); $products_count += $products['total']; // no need to find child categories that are hidden from this customer or have a higher level category that is hidden $child_categories_query = tep_db_query("select categories_id from " . TABLE_CATEGORIES . " where parent_id = '" . (int)$category_id . "' and find_in_set('" . $customer_group_id . "', categories_hide_from_groups) = 0"); // EOF Separate Pricing Per Customer, hide products and categories for groups One thing I forgot to say in my previous email regarding the fast "general.php" file, the shopping cart is NOT working. So I used the slow "general.php" instead. But now, I commented out the two lines above, and it gets much faster and at the same time, the shopping cart works. Great Work. Thanks James Link to comment Share on other sites More sharing options...
Guest Posted May 26, 2007 Share Posted May 26, 2007 Hi JanZ I finished the uninstallation of "Enabled/Disabled" module. Then I install the latest version of Hide Products and Categories. 2 problems are found now. 1. When I disabled a category on the top level, the icon still show. It is the same as before. Even I hide the category from group 0, ONLY the categories on the top level appear. However, it shows nothing inside that category. 2. When clicking the category or the sub-categories, it take quite a long time to wait for the result to appear. About 2 ~ 3 times longer. I think it might be the files that I have installed and uninstall many times. Hi JanZ again, Regarding the 1st problem, I finally found out that the problem is related to one single file, it is the catalog/includes/modules/new_categories.php file. This file functions to display the top-level categories on the front page of oscommerce. It is an upgrade done last year, I forgot. I fixed the problem by replacing the commented line with a code copied from your catalog/includes/boxes/categories.php: //so to make sure your categories are selected, do NOT have "category" in the IMAGE title // BOF SPPC hide categories from groups $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '0' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' and find_in_set('" . $customer_group_id . "', categories_hide_from_groups) = 0 order by sort_order, cd.categories_name"); // EOF SPPC hide categories from groups /*$categories_query =tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '0' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by sort_order, cd.categories_name");*/ Now, the top categories can be hidden by your "Hide Products and Categories" ------- Great Contribution ! However, the hidden categories appear again only in the following situation. Here's my problem regarding the manufacturer box, when I select a manufacturer to make query on his products, the results are shown in the format of two parts: the upper categories icons and the lower product listing. The problem is the upper part where all the top level categories are displayed again, no matter they are hidden or not. Here below is the extract from the once amended file in this directory, catalog/includes/boxes/manufacturers.php if (isset($_GET['cPath'])) { $cPath = $_GET['cPath']; $cPath_length = strlen($cPath); if (($cPath_length != '1') && ($cPath_length != '2')) { list($old_cPath, $new_cPath) = split ('[_]', $cPath); } else { $new_cPath = $cPath; } $cPath_query = tep_db_query("select products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . $new_cPath . "'"); if (!$cPath_num_of_rows = tep_db_num_rows($cPath_query)) { $manufacturers_query = tep_db_query("select distinct m.manufacturers_id, m.manufacturers_name from " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_PRODUCTS . " p, " . TABLE_CATEGORIES . " c where c.parent_id = '" . $new_cPath . "' and p2c.categories_id = c.categories_id and p2c.products_id = p.products_id and p.manufacturers_id = m.manufacturers_id order by m.manufacturers_name"); } else { $manufacturers_query = tep_db_query("select distinct m.manufacturers_id, m.manufacturers_name from " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_PRODUCTS . " p, " . TABLE_CATEGORIES . " c where c.categories_id = '" . $new_cPath . "' and p2c.categories_id = c.categories_id and p2c.products_id = p.products_id and p.manufacturers_id = m.manufacturers_id order by m.manufacturers_name"); } } else { // #################### Added Enable / Disable Categories ############## $manufacturers_query = tep_db_query("select manufacturers_id, manufacturers_name from " . TABLE_MANUFACTURERS . " order by manufacturers_name"); // $manufacturers_query = tep_db_query("select distinct m.manufacturers_id, m.manufacturers_name from " . TABLE_MANUFACTURERS . " m left join " . TABLE_PRODUCTS . " p on m.manufacturers_id = p.manufacturers_id left join " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c on p.products_id = p2c.products_id left join " . TABLE_CATEGORIES . " c on p2c.categories_id = c.categories_id where c.categories_status = '1' and p.products_status = '1' order by m.manufacturers_name"); // #################### End Added Enable / Disable Categories ############## } Am I looking in the correct direction? or if it should be caused by another file, e.g. index.php? I wonder. I hope you have time giving me the next instruction. Thanks in advance. Cheers James Link to comment Share on other sites More sharing options...
Jan Zonjee Posted May 26, 2007 Share Posted May 26, 2007 The problem is the upper part where all the top level categories are displayed again, no matter they are hidden or not. Here below is the extract from the once amended file in this directory, catalog/includes/boxes/manufacturers.php Try this (probably some more needs to be done for hidden products): if (isset($_GET['cPath'])) { $cPath = $_GET['cPath']; $cPath_length = strlen($cPath); if (($cPath_length != '1') && ($cPath_length != '2')) { list($old_cPath, $new_cPath) = split ('[_]', $cPath); } else { $new_cPath = $cPath; } // BOF SPPC if (isset($_SESSION['sppc_customer_group_id']) && $_SESSION['sppc_customer_group_id'] != '0') { $customer_group_id = $_SESSION['sppc_customer_group_id']; } else { $customer_group_id = '0'; } //EOF SPPC $cPath_query = tep_db_query("select products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . $new_cPath . "'"); if (!$cPath_num_of_rows = tep_db_num_rows($cPath_query)) { $manufacturers_query = tep_db_query("select distinct m.manufacturers_id, m.manufacturers_name from " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_PRODUCTS . " p, " . TABLE_CATEGORIES . " c where c.parent_id = '" . $new_cPath . "' and p2c.categories_id = c.categories_id and p2c.products_id = p.products_id and p.manufacturers_id = m.manufacturers_id order by m.manufacturers_name"); } else { $manufacturers_query = tep_db_query("select distinct m.manufacturers_id, m.manufacturers_name from " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_PRODUCTS . " p, " . TABLE_CATEGORIES . " c where c.categories_id = '" . $new_cPath . "' and p2c.categories_id = c.categories_id and p2c.products_id = p.products_id and p.manufacturers_id = m.manufacturers_id order by m.manufacturers_name"); } } else { // #################### BOF Hide Categories for SPPC ############## $manufacturers_query = tep_db_query("select distinct m.manufacturers_id, m.manufacturers_name from " . TABLE_MANUFACTURERS . " m left join " . TABLE_PRODUCTS . " p on m.manufacturers_id = p.manufacturers_id left join " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c on p.products_id = p2c.products_id left join " . TABLE_CATEGORIES . " c on p2c.categories_id = c.categories_id where p.products_status = '1' and find_in_set('".$customer_group_id."', products_hide_from_groups) = 0 and find_in_set('" . $customer_group_id . "', categories_hide_from_groups) = 0 order by m.manufacturers_name"); // #################### EOF Hide Categories for SPPC############## } I guess the queries get too slow when categories are added to the tep_count_products_in_category. I'll take a look if something more efficient can be done. I suppose you use that counter? Link to comment Share on other sites More sharing options...
Guest Posted May 26, 2007 Share Posted May 26, 2007 Hi JanZ Great! In such a short time! You're a genius. This should be done to complete the "Hide products and categories" when query is made on manufacturers. Try this (probably some more needs to be done for hidden products): You're right. The result page of "........index.php?manufacturers_id=...." still display the top category. So, more things have to be done. I guess the queries get too slow when categories are added to the tep_count_products_in_category. I'll take a look if something more efficient can be done. I suppose you use that counter? Looking forward to your further instructions. Thanks in advance. Salute to you! James Link to comment Share on other sites More sharing options...
Jan Zonjee Posted May 26, 2007 Share Posted May 26, 2007 Looking forward to your further instructions. Regarding that, I coded a nice object to reduce the insane amount of queries needed for counting products in categories to just two queries. Might be interesting for more people so I will package it as a contribution this afternoon for both a "normal" shop and one that uses "hide products for sppc". Link to comment Share on other sites More sharing options...
Jan Zonjee Posted May 26, 2007 Share Posted May 26, 2007 I coded a nice object to reduce the insane amount of queries needed for counting products in categories to just two queries. Uploaded it as Optimize categories box with instructions for both a regular shop as well as for "Hide Products from customer groups for SPPC". Link to comment Share on other sites More sharing options...
Guest Posted May 28, 2007 Share Posted May 28, 2007 Uploaded it as Optimize categories box with instructions for both a regular shop as well as for "Hide Products from customer groups for SPPC". Dear JanZ I installed the CountProductsStore.php. The engine improves the speed and the number counted. Especially when I clicked the manufacturer's box and show products of that manufacturers. However, when I search products from the front page, something strange happened. The categories on the top level can be clicked and then display the second level of categories, i.e. the sub-categories. This is normal. However, when I clicked further to display the third level, it just returned to the categories on the top level. And it's just looping. I think this is a small bug. Regarding my previous message, You're right. The result page of "........index.php?manufacturers_id=...." still display the top category. The problem is the upper part where all the top level categories are displayed again, no matter they are hidden or not. I found out that the categories shown on the upper part is casued by one statement in the catalog/index.php Here below is what I've commented and replaced with the one that copied from catalog/includes/boxes/categories.php // check to see if there are deeper categories within the current category /*$categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . $cat_to_search . "' and c.categories_id = cd.categories_id and cd.language_id = '" . $languages_id ."' order by sort_order, cd.categories_name");*/ $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '0' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' and find_in_set('" . $customer_group_id . "', categories_hide_from_groups) = 0 order by sort_order, cd.categories_name"); if (tep_db_num_rows($categories_query) > 0 ) { Now, the problem is fixed. Am I replacing the commented one with the correct code copied from boxes/categories.php? It is from your "Hide products and categories". Should it be rephrased with a new one? Thanks for your help. Looking forward to your revised version of the CountProductsStore module. What a Great professional expert in oscommerce! You're the one! Thanks Cheers James Link to comment Share on other sites More sharing options...
Jan Zonjee Posted May 28, 2007 Share Posted May 28, 2007 James, Looking forward to your revised version of the CountProductsStore module. I wouldn't know what to change because it basically stores results from the database in an object which some methods to get results from it, that would normally be done with a query.However, when I clicked further to display the third level, it just returned to the categories on the top level. And it's just looping. I think you should have changed the '0' in where c.parent_id = '0' to where c.parent_id = '" . $cat_to_search . "' in the below (uncommented) query. Probably that is the cause of your bug. // check to see if there are deeper categories within the current category /*$categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . $cat_to_search . "' and c.categories_id = cd.categories_id and cd.language_id = '" . $languages_id ."' order by sort_order, cd.categories_name");*/ $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '0' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' and find_in_set('" . $customer_group_id . "', categories_hide_from_groups) = 0 order by sort_order, cd.categories_name"); if (tep_db_num_rows($categories_query) > 0 ) { Link to comment Share on other sites More sharing options...
Guest Posted May 30, 2007 Share Posted May 30, 2007 James, I wouldn't know what to change because it basically stores results from the database in an object which some methods to get results from it, that would normally be done with a query. I think you should have changed the '0' in where c.parent_id = '0' to where c.parent_id = '" . $cat_to_search . "' in the below (uncommented) query. Probably that is the cause of your bug. // check to see if there are deeper categories within the current category /*$categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . $cat_to_search . "' and c.categories_id = cd.categories_id and cd.language_id = '" . $languages_id ."' order by sort_order, cd.categories_name");*/ $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '0' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' and find_in_set('" . $customer_group_id . "', categories_hide_from_groups) = 0 order by sort_order, cd.categories_name"); if (tep_db_num_rows($categories_query) > 0 ) { Hi JanZ I changed the "0" but still it is strange. The catgories on the second level return to the top level. I think it might be the problem the front page that I use the new_categories.php. That might not work with the new includes/functions/general.php because when I activate each of the amended file one after the others, the clicking and paths are all okay except the last change before I activate the general.php. When Ido so, the system turned really slow at first and then return to the main page. But any way, the problem must come from my upgraded versions of oscommerce. Perhaps when I have more time in the mid of June, I will test it through on a new oscommerce. BTW, JanZ have you heard of UTF8. I wanted to establish a second oscommerce, but this time Ihope to work on UTF8, but how should I start. Once when I went through the forums, I found one mentioning to save as "all the language files in UTF8". Is this the usual way to do? Cheers James Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.