Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.

helpme

 

Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.

 

Show module in manufacturers products page and search page

Show module in manufacturers products page and search page

Hello there,

I use Joomla 3.6.4 and VM 3.0.18, I created a hidden menu that goes to manufacutrer details page. THere, there is a link to show all products of each manufacturer. I have a link like this:
mysite.com/component/virtuemart/manufacturer/mymanufacturer. There i see all products of this manufacturer.

The second issue is when i try to search something and click enter. Url example like this:
mysite.com/component/virtuemart/search?virtuemart_category_id=0&limitstart=0&option=com_virtuemart&view=category&keyword=mykeyword.

Currently, i use this code:

Code:

$vm = JomGenius("virtuemart"); 

$menu =& JSite::getMenu();

if (!$vm->check("pagetype = category")) return; // show nothing if not on a category page

$cat = $vm->info("category_id");
if (!$cat) return; // show nothing if we can't get a category id
$query = 'select count(*) from #_' . '_virtuemart_product_categories where virtuemart_category_id = \'' . (int)$cat . '\'';
$db->setQuery($query);
$c = $db->loadResult();

if (($c > 1)) {
return 147;
}

So, any ideas of how i could adjust this in order to show module also to manufacturers products page and search result page?

Thank you in advance

pm4698
Beginner Modder
ranks
useravatar
Offline
13 Posts
Administrator has disabled public posting

Re: Show module in manufacturers products page and search page

Hi,
the JomGenius pagetype thing knows about those other page types too:

manufacturer.products (i.e. list of products from a manufacturer)
manufacturer (pure manufacturer page)

You can also use $vm->check("is_search_results") to test if you are on a search results page.

The problem with each of these is that they will use a different mechanism for determining how many results are showing on the page. For categories it's reasonably easy: as above, we count the number of products tagged with that category in the database. For manufacturers there will be a similar SQL query that looks for the number of products tagged with that manufacturer ID (simple enough).
However for search results, every search is different, so I don't think I can give a SQL query that will repeat the actual search and work out how many results there were. And I don't know of any other way to "ask" VM how many search results are on the page. So that one's a dead end for me.

Here's an adjustment to the code you are using, which can take into account manufacturer pages as well as category pages:

$vm = JomGenius("virtuemart");

if ($vm->check("pagetype = category")) {
  $cat = $vm->info("category_id");
  if (!$cat) return; // show nothing if we can't get a category id
  $query = 'select count(*) from #_' . '_virtuemart_product_categories where virtuemart_category_id = \'' . (int)$cat . '\'';
  $db->setQuery($query);
  $c = $db->loadResult();
  if (($c > 1)) {
    return 147;
  }
}
if ($vm->check("pagetype = manufacturer, manufacturer.products")) {
  $man = $vm->info("manufacturer_id");
  if (!$man) return; // show nothing if we can't get a manufacturer id
  $query = 'select count(*) from #_' . '_virtuemart_product_manufacturers where virtuemart_manufacturer_id = \'' . (int)$man . '\'';
  $db->setQuery($query);
  $c = $db->loadResult();
  if (($c > 1)) {
    return 147;
  }
}


I have done some basic testing with this and I think it's along the right lines.

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3329 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1684
Total Polls:
6
Total Posts:
5940
Posts this week:
1
User Info:
 
Total Users:
5161
Newest User:
kbmgkey234q
Members Online:
0
Guests Online:
194

Online: 
There are no members online

Forum Legend:

 Topic
 New
 Locked
 Sticky
 Active
 New/Active
 New/Locked
 New Sticky
 Locked/Active
 Active/Sticky
 Sticky/Locked
 Sticky/Active/Locked