Author Topic: Category name in Related Product  (Read 1766 times)

zeevee

  • Beginner
  • *
  • Posts: 25
    • Euphoric Graphics
Category name in Related Product
« on: November 20, 2008, 17:24:22 pm »
How can I get Category Name in Related Product. I tried $category_name, $cat_name, $category["category_name"]. I am not a PHP expert, somebody please help..

VM 1.1.2
J 1.5.4

hanfred

  • Beginner
  • *
  • Posts: 7
Re: Category name in Related Product
« Reply #1 on: April 04, 2011, 21:57:12 pm »
I've the same problem...:( have you solved?

hanfred

  • Beginner
  • *
  • Posts: 7
Re: Category name in Related Product
« Reply #2 on: April 05, 2011, 23:39:07 pm »
Hi! I've solved :)

I solved :)

for "recover" the category in related product (in productSnapshot.tpl.php file) I solved in this way:

Open ps_product.php file from /administrator/components/com_virtuemart/classes.
Find the product_snapshot function, about line 2440:

     function product_snapshot( $product_sku, $show_price=true, $show_addtocart=true, $show_product_name = true )

Find the first "if" in the function

    if ($db->next_record()) {

after the line

     $cid = $ps_product_category->get_cid( $product_id );

insert the follow code

$q2 = "SELECT category_name FROM #__{vm}_category WHERE category_id=$cid";
         $db2->query( $q2 );
         if ($db2->next_record()){
            $category_name = $db2->f("category_name");
         }

         $tpl->set( 'product_category_name', $category_name);

In this way we have the category name of the product and the value that we assigned to the variable product_category_name that will be invoked by our file productsnapshot.tpl.php

So now we have to open the file productSnapshot.tpl.php from /components/com_virtuemart/themes/default/template/common and insert the following code where we want to show the product category

    echo $product_category_name;

So we have reached the goal: "recover" the product category from related productd

PS: I'm really sorry for my bad english but I'm a italian student and I don't speak english very well :)

dontflinch

  • Jr. Member
  • **
  • Posts: 152
Re: Category name in Related Product
« Reply #3 on: April 20, 2011, 20:50:25 pm »
thank you!