{"id":243,"date":"2010-03-28T02:12:36","date_gmt":"2010-03-28T00:12:36","guid":{"rendered":"http:\/\/kavdesign.net\/wordpress\/?p=243"},"modified":"2010-03-28T02:18:01","modified_gmt":"2010-03-28T00:18:01","slug":"how-to-hack-manufacturer-name-description-or-logo-in-virtuemart-browse-page-template","status":"publish","type":"post","link":"https:\/\/www.kavdesign.net\/blog\/coding\/how-to-hack-manufacturer-name-description-or-logo-in-virtuemart-browse-page-template\/","title":{"rendered":"How to hack Manufacturer Name, Description or logo in Virtuemart Browse Page Template"},"content":{"rendered":"<p>First of all, let&#8217;s open these three files first:<\/p>\n<blockquote>\n<ol>\n<li>shop.browse.php in  \/administrator\/components\/com_virtuemart\/html\/shop.browse.php<\/li>\n<li>ps_product.php (Open this for explanation purpose)<\/li>\n<li>browse_1.php (The browse page in which your browse page is using)<\/li>\n<\/ol>\n<\/blockquote>\n<p><!--more--><\/p>\n<p><strong>Shop.browse.php<\/strong><\/p>\n<p>Search for this line:<\/p>\n<blockquote><p>\/\/ NOW START THE PRODUCT LIST<br \/>\n$tpl = vmTemplate::getInstance();<\/p><\/blockquote>\n<p>All code will be inserted after the line above. That created the object  of class vmTemplate.<\/p>\n<p>Before the add to cart button:<\/p>\n<blockquote><p>\/\/ Add-to-Cart Button<\/p><\/blockquote>\n<p>I insert the codes to set the manufacturer description (or name). In the manufacturer description I only have one image, which is the logo of the manufacturer.<\/p>\n<blockquote><p><span style=\"color: #993366;\">$mf_desc = $ps_product-&gt;get_mf_desc( $db_browse-&gt;f(&#8216;product_id&#8217;)  );<br \/>\n$tpl-&gt;set(&#8216;mf_desc&#8217;,$mf_desc);<\/span><\/p>\n<p><span style=\"color: #993366;\">$mf_id = $ps_product-&gt;get_manufacturer_id( $db_browse-&gt;f(&#8216;product_id&#8217;) );<br \/>\n$tpl-&gt;set(&#8216;mf_id&#8217;,$mf_id);<\/span><\/p>\n<p><span style=\"color: #993366;\"><span style=\"color: #000000;\">Put this code:<\/span><br \/>\n<\/span><\/p>\n<p><span style=\"color: #993366;\">$products[$i][&#8216;mf_desc&#8217;] = $mf_desc;<br \/>\n$products[$i][&#8216;mf_id&#8217;] = $mf_id;<\/span><\/p>\n<p>right before : } \/\/ END OF  while loop<\/p><\/blockquote>\n<p>Note: Do not put the code above inside any if condition statement after  the\u00a0 $tpl = vmTemplate::getInstance(); Otherwise, the codes might not  work probably.<\/p>\n<p>So, you might ask what does this line say about:<br \/>\n<strong>$ps_product-&gt;get_mf_desc( $db_browse-&gt;f(&#8216;product_id&#8217;) );<\/strong><\/p>\n<p>PS_product is the PHP class file &#8220;ps_product.php&#8221;.<\/p>\n<p><strong>ps_product.php<\/strong><\/p>\n<p>Inside this class, we found a method\/function called &#8220;get_mf_name&#8221;.<br \/>\nAnd the method get_mf_name require a passin reference &#8220;product_id&#8221;.<\/p>\n<p>We create a method called get_mf_desc after the get_mf_name method we put:<\/p>\n<blockquote><p><span style=\"color: #993366;\">\/**<br \/>\n* Functon to get the description of the manufacturer this product is assigned to<br \/>\n*<br \/>\n* @param int $product_id<br \/>\n* @return string the manufacturer description<br \/>\n*\/<br \/>\nfunction get_mf_desc($product_id) {<br \/>\n$db = new ps_DB;<\/span><\/p>\n<p>$q = &#8220;SELECT mf_desc,#__{vm}_manufacturer.manufacturer_id FROM #__{vm}_product_mf_xref,#__{vm}_manufacturer &#8220;;<br \/>\n$q .= &#8220;WHERE product_id=&#8217;$product_id&#8217; &#8220;;<br \/>\n$q .= &#8220;AND #__{vm}_manufacturer.manufacturer_id=#__{vm}_product_mf_xref.manufacturer_id&#8221;;<\/p>\n<p>$db-&gt;query($q);<br \/>\n$db-&gt;next_record();<br \/>\nif ($db-&gt;f(&#8220;mf_desc&#8221;)) {<br \/>\nreturn $db-&gt;f(&#8220;mf_desc&#8221;);<br \/>\n}<br \/>\nelse {<br \/>\nreturn &#8220;&#8221;;<br \/>\n}<br \/>\n}<\/p><\/blockquote>\n<p>To get each product id in browse page, we have this build in function: <strong>$db_browse-&gt;f(&#8216;product_id&#8217;)<\/strong><\/p>\n<p>Lastly, we put this &#8220;TAG&#8221; $mf_desc in our browse template  file:browse_1.php<\/p>\n<p><strong>browse_1.php<\/strong><\/p>\n<blockquote><p>&lt;a href=&#8221;&lt;?php echo $sess-&gt;url( URL.&#8221;index.php?option=com_virtuemart&amp;page=shop.browse&amp;manufacturer_id=&#8221;. $mf_id ) ?&gt;&#8221; target=&#8221;_parent&#8221;&gt;<br \/>\n&lt;?php echo $mf_desc; ?&gt;<br \/>\n&lt;\/a&gt;<\/p><\/blockquote>\n<p>Straight forward? Just echo the variables we defined before.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>First of all, let&#8217;s open these three files first: shop.browse.php in \/administrator\/components\/com_virtuemart\/html\/shop.browse.php ps_product.php (Open this for explanation purpose) browse_1.php (The browse page in which your<\/p>\n<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"https:\/\/www.kavdesign.net\/blog\/coding\/how-to-hack-manufacturer-name-description-or-logo-in-virtuemart-browse-page-template\/\">Continue reading<span class=\"screen-reader-text\">How to hack Manufacturer Name, Description or logo in Virtuemart Browse Page Template<\/span><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_links_to":"","_links_to_target":""},"categories":[9],"tags":[57,56,55,54,33],"class_list":["post-243","post","type-post","status-publish","format-standard","hentry","category-coding","tag-browse-page","tag-description","tag-logo","tag-manufacturer","tag-virtuemart","entry"],"_links":{"self":[{"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/posts\/243","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/comments?post=243"}],"version-history":[{"count":6,"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/posts\/243\/revisions"}],"predecessor-version":[{"id":249,"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/posts\/243\/revisions\/249"}],"wp:attachment":[{"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/media?parent=243"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/categories?post=243"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/tags?post=243"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}