rickobee Posted March 15, 2017 Share Posted March 15, 2017 Is it possible at all to make the manufacturers field behave as a tag? So the manufacturer on a product page would link to all products from that manufacturer? If not, is it possible to search manufacturers? Or perhaps build a link that would return those results? In my case, I'm building a shop for books so I'd love some sort of tag (or tag-like) system for either publishers or authors. I searched the forums and Google with every combination I could think of but am hoping I've just missed the solution somewhere. Thanks very much, Quote Link to comment Share on other sites More sharing options...
bsmither Posted March 15, 2017 Share Posted March 15, 2017 You would need a Code Snippet. The standard search mechanism must have keywords to search on. Then, from the Advanced Search page, you can filter against chosen Manufacturers. You may think that one can search for wild-card anything, and name the manufacturer in the URL, but it doesn't work that way - unfortunately. Here is a Code Snippet you can try: In admin, Manage Hooks, Code Snippets tab, click Add Snippet. Enabled: checked Unique ID: search_specific@cubecart -- max 32 chars Execution Order: 1 Description: Allows to search for specific properties Trigger: class.catalogue.pre_search Version: 1.0 Author: https://forums.cubecart.com/topic/52317-turn-manufacturer-field-into-a-tag/ PHP Code: <?php /* Specify in the array the names of the columns containing specific value properties of the inventory. * That is, the property that uniquely identifies an item. * Use the actual names of the columns holding these properties. */ $specific_properties = array( 'found' => "Publisher", // Found "what" on the Search Results page 'table' => "CubeCart_manufacturers", 'alias' => "CCM", 'on' => array('master' => "I.manufacturer", 'slave' => "id"), 'column' => array("name"), ); foreach($specific_properties['column'] as $property) { if(isset($search_data[$specific_properties['alias']][$property]) && !empty($search_data[$specific_properties['alias']][$property])) { $search_mode = ($search_mode == 'RLIKE' || $search_mode == 'LIKE') ? $search_mode : 'RLIKE'; // Can't use fulltext - not using fulltext index $_REQUEST['search']['keywords'] = $specific_properties['found'].":".$search_data[$specific_properties['alias']][$property]; // Needed to show on Search Results page $joins[] = sprintf( '%1$s'.$specific_properties['table']." AS ".$specific_properties['alias'] .' ON '.$specific_properties['on']['master'].' = '.$specific_properties['alias'].'.'.$specific_properties['on']['slave'] ,$GLOBALS['config']->get('config', 'dbprefix') ); $where[] = $specific_properties['alias'].".".$property." LIKE ".$GLOBALS['db']->sqlSafe("%".$search_data[$specific_properties['alias']][$property]."%",true); // example, searching for "%Riley%" anywhere in the name; } } Now, this gives you a specific URL you can use to initiate a search. That is to say, if you put this URL as a link on a page, CubeCart will perform a search for what you want: http://www.mystore.com/search.html?search%5BCCM%5D%5Bname%5D=Riley&_a=category where Riley is part of the Manufacturer's name. 1 Quote Link to comment Share on other sites More sharing options...
havenswift-hosting Posted March 15, 2017 Share Posted March 15, 2017 6 hours ago, rickobee said: Is it possible at all to make the manufacturers field behave as a tag? So the manufacturer on a product page would link to all products from that manufacturer? If not, is it possible to search manufacturers? Or perhaps build a link that would return those results? We have a plugin that provides all this and more. It isn't on the marketplace yet but available from our website Ian 1 Quote Link to comment Share on other sites More sharing options...
rickobee Posted March 16, 2017 Author Share Posted March 16, 2017 Quote Now, this gives you a specific URL you can use to initiate a search. That is to say, if you put this URL as a link on a page, CubeCart will perform a search for what you want: http://www.mystore.com/search.html?search%5BCCM%5D%5Bname%5D=Riley&_a=category where Riley is part of the Manufacturer's name. bsmither, this works perfectly. Thanks so much! And the ability to add functionality without editing code is brilliant, what a great feature. Thanks again! 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.