New Zenner
- Join Date:
- Feb 2006
- Posts:
- 85
- Plugin Contributions:
- 0
hideCategories
I was just wondering, if it would be easier to create a new product type, that it's own rules, than it would be to try and hide a category.. Just a thought.
Views: 105,228
New Zenner
I was just wondering, if it would be easier to create a new product type, that it's own rules, than it would be to try and hide a category.. Just a thought.
Zen Follower
Help
I am trying to hide all the products in a category from the search. Th category is invisable so it is not showing up in my menu and I have instaleed the module with no problesm, however the products show up in the search - is there any way to hide these completely so they don't show up in the search.
Totally Zenned
Hi folks,
The answer to everything is "yes". You can do that. As I stated in the first post, I made this specifically for our store and its not a contrib I plan to support at all since there's a million things you could want that someone else wouldn't. Its nearly impossible to release this contrib so that it works for everyone. You'll need to modify it yourself to do what you want.
For example the search request: You'll have to find wherever in Zen the search function(s) exist and have them check to see the hidden status of the category before adding any given product to the results. The hard part is finding the appropriate functions. Once you do, it should be fairly easy. Look at the other files included in the package for hints and how I did it.
Obviously, it takes a good understanding of PHP/SQL as well as good level of zen structure knowledge.
Sorry I can't spend the time with individual requests. I provided the basis... I hope you can use it to get where you want to be.
Zen Follower
Cheers for your quick reply.
All I need is one category and everything inside this to be hidden.
I kinda presumed this is what the hide category module does? as right now installed on 1.37 it just does exactly the same as changing the staus button to red - is that correct? (or am I being incredibly dumb :-) )
I am reckon I am missing something v.v.v.v basic and I appreciate you don't take requests but as I have only enough php knowledge to allow me to install zen cart I wouldn't even know where to start with functions etc.
Is there anyway you could nudge me in the right direction the only thing I have noticed which may cause it to work as a hide item is there is code in the tpl_products_all file - should this hide code be on all products templates you use?
Sorry to be a pest and thanks for taking the time to reply.
Totally Zenned
peanut77:
Help
I am trying to hide all the products in a category from the search. Th category is invisable so it is not showing up in my menu and I have instaleed the module with no problesm, however the products show up in the search - is there any way to hide these completely so they don't show up in the search.
If the module is installed correctly, it shouldn't show up in the search. I had an error with includes/modules/MY_TEMPLATE/product_listing.php, and that caused the producy to NOT be hidden in the search. After I put product_listing.php in the right folder, the product no longer showed up in the search.
Zen Follower
Jettrue
Your a complete and utter star!! that is all that is was - I thought i'd been through everything with a fine toothcomb!!
Thank you for pointing me in the right direction - much aprreciated.
Zen Follower
HI STEVEN
IT's a great contribution, but there is a problem, when I use css flyout category sidebox or header css flyout, the hidden categories are still showing!!!
do you now how can I solve this problem?
thanks
Zen Follower
Just wanted to say that I installed this mod tonight and I love it.
Thank you!
Tatiana:clap:
Totally Zenned
john95051:
I am having problem on the 1.36 ZC.
I got following when I click "New Product",
1146 Table 'jun9505_jlcxxxxxx.products_description' doesn't exist
in:
[select count(*) as total FROM jun9505_products p LEFT JOIN jun9505_manufacturers m ON (p.manufacturers_id = m.manufacturers_id) LEFT JOIN jun9505_hide_categories h ON (p.master_categories_id = h.categories_id), products_description pd WHERE (h.visibility_status < 2 OR h.visibility_status IS NULL) AND p.products_status = 1 AND p.products_id = pd.products_id AND pd.language_id = 1 ]Note, jlcxxxxxx is the database name, jun9505 is the prefix.
If everything is right, It should looking for Table 'jun9505_products_description'. Any idea on why this happen?Thanks.
s_mack:
When you put in the included SQL, how did you do it? I've seen this problem come up and this question asked on just about every contrib support forum out there :) I don't know how table prefixes work because mine don't use them (I don't understand why anyone's do)... but the answer always seems to be "input the SQL into phpmyadmin, NOT the SQL tool in your Zen admin!"
Good luck. I'm pretty sure its not a problem with this contrib though.
- Steven
The jun9505 it's not the prefix is the username of your hosting account.
Smack, I tried your solution, and doesn't fix the issue. I think your SQL query is missing a "description" table? I'm not programmer but that's what it looks from my error as well as the previous poster. The system somehow it's looking for a description that doesn't exist on the table???
Again... I really don't know since I'm not programmer but this issue only comes up when I install this module (which I love BTW).
This is my error:
1146 Table 'USER_DATABASENAME.products_description' doesn't exist
in:
[select count(*) as total FROM _zenproducts p LEFT JOIN _zenmanufacturers m ON (p.manufacturers_id = m.manufacturers_id) LEFT JOIN _zenhide_categories h ON (p.master_categories_id = h.categories_id), products_description pd WHERE (h.visibility_status < 2 OR h.visibility_status IS NULL) AND p.products_status = 1 AND p.products_id = pd.products_id AND pd.language_id = 1 ]
Is it posible for you or any of the other coder guru look into this?
IDEASLady
IDEAS Creative Studio
Your image... our business!
Totally Zenned
Someone else will have to help. I'm really short on time, but more than that... I really just don't get the whole prefix thing as I've never used them... the two that have had problems, it is related to prefixes.
Its not missing a description table. "products_description" exists, but "USER_DATABASENAME.products_description" does not... why your cart is trying to add that prefix is what I don't understand.
I'm sure its not complicated... and I'm sure someone that gets prefixes can answer exactly what you have to do. I've personally never worked with a host that does that. I don't even know why or when prefixes come about. So I can't help. But its not the contrib... or if it is, it is only the contrib on hosts like yours that use prefixes.
New Zenner
ideasgirl:
The system somehow it's looking for a description that doesn't exist on the table???
ideasgirl, it appears you're having the same problem I had. The system is looking for a table without a prefix because the constant DB_PREFIX is missing in the PHP code.
Have a look at page 5 of this thread, the last reply (direct link here: http://www.zen-cart.com/forum/showpost.php?p=338852&postcount=50 )
This seems to have fixed the problem for me.
good luck,
marc...
Totally Zenned
This seems to have fixed the problem for me.
It did it for me as well... thanks! :yes:
IDEASLady
IDEAS Creative Studio
Your image... our business!
Totally Zenned
Oh right... jeeze... I thought I had fixed that! I'm uploading now.
Thanks.
New Zenner
I modified it to stop it from displaying products in a completely hidden category from showing up in the "also bought" box.
Here are the changes:
In includes/class/db/mysql/define_queries.php
Change:
DEFINE('SQL_ALSO_PURCHASED', "select p.products_id, p.products_image
from " . TABLE_ORDERS_PRODUCTS . " opa, " . TABLE_ORDERS_PRODUCTS . " opb, "
. TABLE_ORDERS . " o, " . TABLE_PRODUCTS . " p
where opa.products_id = '%s'
and opa.orders_id = opb.orders_id
and opb.products_id != '%s'
and opb.products_id = p.products_id
and opb.orders_id = o.orders_id
and p.products_status = 1
group by p.products_id
order by o.date_purchased desc
limit " . MAX_DISPLAY_ALSO_PURCHASED);
To:
DEFINE('SQL_ALSO_PURCHASED', "select p.products_id, p.products_image
from " . TABLE_ORDERS_PRODUCTS . " opa, " . TABLE_ORDERS_PRODUCTS . " opb, "
. TABLE_ORDERS . " o, " . TABLE_PRODUCTS . " p, " . TABLE_HIDE_CATEGORIES . " h
where opa.products_id = '%s'
and opa.orders_id = opb.orders_id
and opb.products_id != '%s'
and opb.products_id = p.products_id
and opb.orders_id = o.orders_id
and p.products_status = 1
and (p.master_categories_id = h.categories_id and h.visibility_status !=2)
group by p.products_id
order by o.date_purchased desc
limit " . MAX_DISPLAY_ALSO_PURCHASED);
This modifies the query that generates content for the "also purchased" box to exclude products in totally hidden categories. The only problem with this is that categories that have never been set to be hidden or not are also excluded.
For pre-existing categories, you must explicitly set them to be normal. For those comfortable with doing so, you can simply insert records into the "hidden_categories" table with all your category IDs.
For new categories, the following modification will automatically insert a record into the table for you.
In admin/categories.php, you need to find the bottom of the code block that contains the code for inserting a new record. In the current version of Zen Cart (1.3.7.1), this is located at aprox. line 196.
The unmodified code looks like this:
if ($has_type->RecordCount() < 1) {
$insert_sql_data = array('category_id' => $categories_id,
'product_type_id' => $parent_product_type->fields['product_type_id']);
zen_db_perform(TABLE_PRODUCT_TYPES_TO_CATEGORY, $insert_sql_data);
}
}
}
} elseif ($action == 'update_category') {
$update_sql_data = array('last_modified' => 'now()');
Change it to this:
if ($has_type->RecordCount() < 1) {
$insert_sql_data = array('category_id' => $categories_id,
'product_type_id' => $parent_product_type->fields['product_type_id']);
zen_db_perform(TABLE_PRODUCT_TYPES_TO_CATEGORY, $insert_sql_data);
}
}
}
// INSERT THE LINE BELOW!!!
zen_db_perform(TABLE_HIDE_CATEGORIES, array('categories_id' => $categories_id, 'visibility_status' => 0));
// INSERT THE LINE ABOVE!!!
} elseif ($action == 'update_category') {
$update_sql_data = array('last_modified' => 'now()');
This will create a record in the hide_categories table for all new categories, and set them to be normal.
Next up will be a modification to prevent hidden products form showing up in the "new products" box.
New Zenner
Ok. To remove hidden products from the "Whats New" box, you need to edit
includes/modules/sideboxes/whats_new.php
On line 15, change the query from
$random_whats_new_sidebox_product_query = "select p.products_id, p.products_image, p.products_tax_class_id, p.products_price
from " . TABLE_PRODUCTS . " p
where p.products_status = 1 " . $display_limit . "
limit " . MAX_RANDOM_SELECT_NEW;
To
$random_whats_new_sidebox_product_query = "select p.products_id, p.products_image, p.products_tax_class_id, p.products_price
from " . TABLE_PRODUCTS . " p, " . TABLE_HIDE_CATEGORIES . " h
where p.products_status = 1
and (p.master_categories_id = h.categories_id and h.visibility_status !=2)
" . $display_limit . "
limit " . MAX_RANDOM_SELECT_NEW;
As before, this only works correctly if every category has an entry in the hidden_categories table.
Totally Zenned
To avoid having to make every category have an entry in hidden_categories, you can do a two-parter.. simply check if it has an entry first, and if it does, check what its status is. If not, operate as normal. More work on the coding, but a LOT less work on the admin.
Zen Follower
I haven't tried this mod, but it seems as if it might resolve a problem that I have with my store. It would appear that there is a bug in ZC 1.3.7 (and 1.3.7.1) if one uses 'linked' products, in that in some circumstances a product's 'linked' category appears to take precedence over the product's master category - according to ajeh, it's a bug due to be fixed in release 1.3.8 but there is not ETA for 1.3.8!!
To explain - you might have a product A (of a series A;B;C...) in Master category 'Brand' which, for example, is linked to sizes 1;2;3;4; & 5 in the 'Size' category. You select the product via the Brand category menu, but the product appears with all the header info relating to one of the product's 'linked sizes', and the previous/next buttons take you to other products of the same size, not of the same brand!!
I have included the available sizes for all the products as product attributes, but the sizes are not found in a search by using the ZC search box - even in the advanced mode of the search.
I am sure that some of my customers would like to search my site via Size, so here are my questions - if I were to use the Hide categories mod, and include a Size category, but hide it, and then link my products to the size category:
a) I presume that the ZC search for items by Size will work
b) will it overcome the 'linked items' bug that I have described?
Or does someone know of a way to facilitate a search by attributes?
Contribution: Attribute Pop-up (Large Images)
Zen Follower
This mod is awesome!! I love it.. I even figured out how to password protect the categories using htaccess and sefu with access to different users woo
I was wondering though... when I search via the sidebox search the products in the category still show up. It doesnt with advanced search but with the sidebox.. how do I have it not show up in the sidebox search?
Totally Zenned
blag:
so here are my questions - if I were to use the Hide categories mod, and include a Size category, but hide it, and then link my products to the size category:
a) I presume that the ZC search for items by Size will work
b) will it overcome the 'linked items' bug that I have described?Or does someone know of a way to facilitate a search by attributes?
I'm sorry, but your needs go way beyond help by me :) I knew stuff like this would come up when I made this mod and that's the problem with it - there's no cap to what you can want to do with it, and there's no way (short of quitting my job) to keep everyone happy and implement everything. I'm sure you can do what you want, but I have no experience with linked categories at all. Best of luck.
CyberWoolf:
This mod is awesome!! I love it.. I even figured out how to password protect the categories using htaccess and sefu with access to different users woo
I was wondering though... when I search via the sidebox search the products in the category still show up. It doesnt with advanced search but with the sidebox.. how do I have it not show up in the sidebox search?
This should be easier, but again - I can't really help... no time. I've left hints in the readme on how to modify files yourself to work with the hidden categories. I hope it helps.
Zen Follower
CyberWoolf:
This mod is awesome!! I love it.. I even figured out how to password protect the categories using htaccess and sefu with access to different users woo
I was wondering though... when I search via the sidebox search the products in the category still show up. It doesn't with advanced search but with the sidebox.. how do I have it not show up in the sidebox search?
Can you post your solution on how you have this mod working so it allows access to the hidden categories to different users. Or even better uploaded the ungraded module in the downloads section. I believe that a lot of people here would be really excited to see that upgrade.
S_mack I think this is a great module and I know you don't have time to modify the module to incorporate extra features. That is the whole point of a community. For those that work out a solution they add it back to the community. I think you have contributed a hell of a lot that you answer everyones post, not always with a direct solution, but with idea of where to look.
Tell staff why this post should be reviewed.