Author Topic: Modules Latest and Featured Products with Text  (Read 19791 times)

Mala

  • Beginner
  • *
  • Posts: 8
Modules Latest and Featured Products with Text
« on: May 23, 2008, 15:48:27 pm »
Hi all,

want to display the Short Description beside the product image in the featured products module and the latest products module. Seems like this is not possible by default.

But if anybody can tell me where I have to insert some code to achieve this it would be very great.

Every idea would be welcome.


Thanks in advance
Yours Mala


P. S.: If there exists a solution, I didn´t find it after searching here and elsewhere more than two hours. So I think it´s ok to post the question here.

GuyUK

  • Beginner
  • *
  • Posts: 5
Re: Modules Latest and Featured Products with Text
« Reply #1 on: June 17, 2008, 17:38:58 pm »
I would like to do the same thing with displaying the short product description next to he featured products.

I find it difficult to believe that no-one has done this so far ! Or do I need to delve into the code  ;D

jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 26910
  • Always on vacation
    • Jenkin Hill Internet
Re: Modules Latest and Featured Products with Text
« Reply #2 on: June 21, 2008, 13:05:54 pm »
Try editing productsnapshot.tpl.php

/compoents/com_virtuemart/themes/default/templates/common/
Kelvyn

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Currently using VM.3.2.15.9866 on Joomla 3.8.10 PHP 7.0.30

Testing VM.3.2.15.9898 on J3.8.10

feuerfest

  • Beginner
  • *
  • Posts: 2
Re: Modules Latest and Featured Products with Text
« Reply #3 on: June 23, 2008, 13:00:33 pm »
Just for the record as this thing appears as first in google search for "full text in featured virtuemart"

File:

Code: [Select]
administrator/components/com_virtuemart/classes/ps_product.php
you have to add

Code: [Select]
, product_s_desc
to SQL query, to basically pull it out  then you have to set it

somewhere after
Code: [Select]
if ($db->next_record()) {
put

Code: [Select]
$tpl->set('product_s_desc',$db->f("product_s_desc"));
then edit the tpl file mentioned above to make it
Code: [Select]
echo $product_s_desc.

Done.

jay blaq

  • Beginner
  • *
  • Posts: 30
Re: Modules Latest and Featured Products with Text
« Reply #4 on: June 26, 2008, 04:51:45 am »
Try joining JXTC and download the FEATURED PRODUCTS EXTENDED MODULE for VM1.1

joomlaxtc.com

GuyUK

  • Beginner
  • *
  • Posts: 5
Re: Modules Latest and Featured Products with Text
« Reply #5 on: July 01, 2008, 19:23:25 pm »
Jenkinhill and fuerfest

Thankyou both for your help here, I can now get the short description across and I need to just sort out the formatting now. But that is easy in comparison.

ltempest

  • Jr. Member
  • **
  • Posts: 118
    • Tempest Photography
Re: Modules Latest and Featured Products with Text
« Reply #6 on: October 23, 2008, 12:44:11 pm »
Help I'm trying to follow Jenkinhill's hack, but do not know which line numbers of the ps_product.php file to add the new code into. There are numerous places the
Code: [Select]
if ($db->next_record()) { code exisits and I don't know which one to add to.

Can you please inform me exactly which lines to add both the sql query and template code to.

Thanks

Lee

Marc O.

  • Jr. Member
  • **
  • Posts: 78
    • Onrust Yacht Charters
Re: Modules Latest and Featured Products with Text
« Reply #7 on: January 06, 2009, 21:10:44 pm »
Bump

I'm also very interested in having the short description added to my featured products. Just like the previous poster, I would like to ask where to enter the lines exactly as there are 11 (I believe) instances of
Code: [Select]
if ($db->next_record()) {
in mentioned file.

spoonbender

  • Beginner
  • *
  • Posts: 5
Re: Modules Latest and Featured Products with Text
« Reply #8 on: February 09, 2009, 05:55:41 am »
@Marc O.

Look for "function product_snapshot"

That's where you will add ", product_s_desc" and "$tpl->set('product_s_desc',$db->f("product_s_desc"));"

I almost read the whole file, haha. Until I realized to look for "fetch( 'common/productsnapshot.tpl.php');"

Marc O.

  • Jr. Member
  • **
  • Posts: 78
    • Onrust Yacht Charters
Re: Modules Latest and Featured Products with Text
« Reply #9 on: February 09, 2009, 15:01:45 pm »
Hi Spoonbender,

Thanks for sharing! Unfortunately I cannot get it to work properly.

Below I pasted the code under function product_snapshot. Can you please let me know where to enter the 2 lines exactly? I tried several positions but it just doesn't show the short desc.

Code: [Select]
function product_snapshot( $product_sku, $show_price=true, $show_addtocart=true, $show_product_name = true  ) {



global $sess, $mm_action_url;



$db = new ps_DB;



require_once(CLASSPATH.'ps_product_category.php');

$ps_product_category = new ps_product_category;



$q = "SELECT product_id, product_name, product_parent_id, product_thumb_image FROM #__{vm}_product WHERE product_sku='$product_sku'";

$db->query( $q );



if ($db->next_record()) {

$product_id = $db->f("product_id" );

$tpl = new $GLOBALS['VM_THEMECLASS']();



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



$tpl->set( 'product_id', $product_id);

$tpl->set( 'product_name', $db->f("product_name") );

$tpl->set( 'show_product_name', $show_product_name );



if ($db->f("product_parent_id")) {

$url = "?page=shop.product_details&category_id=$cid&flypage=".$this->get_flypage($db->f("product_parent_id"));

$url .= "&product_id=" . $db->f("product_parent_id");

} else {

$url = "?page=shop.product_details&category_id=$cid&flypage=".$this->get_flypage($db->f("product_id"));

$url .= "&product_id=" . $db->f("product_id");

}

$product_link = $sess->url($mm_action_url. "index.php" . $url);

$tpl->set( 'product_link', $product_link );

$tpl->set( 'product_thumb_image', $db->f("product_thumb_image"), "alt=\"".$db->f("product_name")."\"");

if (_SHOW_PRICES == '1' && $show_price) {

// Show price, but without "including X% tax"

$price = $this->show_price( $db->f("product_id"), true );

$tpl->set( 'price', $price );

}

if (USE_AS_CATALOGUE != 1 && $show_addtocart

&& isset( $GLOBALS['product_info'][$product_id]['price']['product_price_id'] ) // Product must have a price to add it to cart

&& !$this->product_has_attributes($product_id, true)  // Parent Products and Products with attributes can't be added to cart this way

) {

$url = "?page=shop.cart&func=cartAdd&product_id=" .  $db->f("product_id");

$addtocart_link = $sess->url($mm_action_url. "index.php" . $url);

$tpl->set( 'addtocart_link', $addtocart_link );
}
return $tpl->fetch( 'common/productsnapshot.tpl.php');

}



return '';



}


spoonbender

  • Beginner
  • *
  • Posts: 5
Re: Modules Latest and Featured Products with Text
« Reply #10 on: February 12, 2009, 15:30:27 pm »
Quote
function product_snapshot( $product_sku, $show_price=true, $show_addtocart=true, $show_product_name = true  ) {

      global $sess, $mm_action_url;
      $db = new ps_DB;

      require_once(CLASSPATH.'ps_product_category.php');
      $ps_product_category = new ps_product_category;

      $q = "SELECT product_id, product_name, product_parent_id, product_thumb_image, product_s_desc FROM #__{vm}_product WHERE product_sku='$product_sku'";

      $db->query( $q );
      if ($db->next_record()) {
         $product_id = $db->f("product_id" );
         $tpl = new $GLOBALS['VM_THEMECLASS']();
         $cid = $ps_product_category->get_cid( $product_id );
         $tpl->set( 'product_id', $product_id);
         $tpl->set( 'product_name', $db->f("product_name") );
         $tpl->set( 'show_product_name', $show_product_name );
         $tpl->set( 'product_s_desc', $db->f("product_s_desc"));
         if ($db->f("product_parent_id")) {

            $url = "?page=shop.product_details&category_id=$cid&flypage=".$this->get_flypage($db->f("product_parent_id"));

            $url .= "&product_id=" . $db->f("product_parent_id");
         } else {

            $url = "?page=shop.product_details&category_id=$cid&flypage=".$this->get_flypage($db->f("product_id"));

            $url .= "&product_id=" . $db->f("product_id");
         }
         $product_link = $sess->url($mm_action_url. "index.php" . $url);
         $tpl->set( 'product_link', $product_link );
         $tpl->set( 'product_thumb_image', $db->f("product_thumb_image"), "alt=\"".$db->f("product_name")."\"");

         if (_SHOW_PRICES == '1' && $show_price) {
            // Show price, but without "including X% tax"
            $price = $this->show_price( $db->f("product_id"), true );
            $tpl->set( 'price', $price );
         }

         if (USE_AS_CATALOGUE != 1 && $show_addtocart
               && isset( $GLOBALS['product_info'][$product_id]['price']['product_price_id'] ) // Product must have a price to add it to cart

               && !$this->product_has_attributes($product_id, true)  // Parent Products and Products with attributes can't be added to cart this way
               ) {
            $url = "?page=shop.cart&func=cartAdd&product_id=" .  $db->f("product_id");
            $addtocart_link = $sess->url($mm_action_url. "index.php" . $url);
            $tpl->set( 'addtocart_link', $addtocart_link );
            }
         return $tpl->fetch( 'common/productsnapshot.tpl.php');
      }
      return '';
   }

There you go... Now edit
Quote
/compoents/com_virtuemart/themes/default/templates/common/productsnapshot.tpl.php
and put
Quote
echo $product_s_desc
anywhere that fits your page.

Marc O.

  • Jr. Member
  • **
  • Posts: 78
    • Onrust Yacht Charters
Re: Modules Latest and Featured Products with Text
« Reply #11 on: February 12, 2009, 15:55:11 pm »
Oh YES, spoonbender, you are my hero!! ;D ;D ;D

It works now, thanks to your hints! In the end I had to add

Code: [Select]
<?php
if( !empty($product_s_desc) ) {
echo $product_s_desc;
}
?>
<br />

instead of just

Code: [Select]
echo $product_s_desc;
Nice work, thanks a mill for your help!!

james123

  • Jr. Member
  • **
  • Posts: 96
Re: Modules Latest and Featured Products with Text
« Reply #12 on: February 14, 2009, 05:09:41 am »
Just D/L this module from joomlaXTC. Works great!

Marc O.

  • Jr. Member
  • **
  • Posts: 78
    • Onrust Yacht Charters
Re: Modules Latest and Featured Products with Text
« Reply #13 on: February 14, 2009, 08:39:18 am »
Do you have a direct link, because I couldn't find it on their website?

bobysolo

  • Beginner
  • *
  • Posts: 47
  • Kiss my shiny metal ass!
    • Videosorveglianza
Re: Modules Latest and Featured Products with Text
« Reply #14 on: July 31, 2009, 11:45:42 am »
Just for the record as this thing appears as first in google search for "full text in featured virtuemart"

File:

Code: [Select]
administrator/components/com_virtuemart/classes/ps_product.php
you have to add

Code: [Select]
, product_s_desc
to SQL query, to basically pull it out  then you have to set it

somewhere after
Code: [Select]
if ($db->next_record()) {
put

Code: [Select]
$tpl->set('product_s_desc',$db->f("product_s_desc"));
then edit the tpl file mentioned above to make it
Code: [Select]
echo $product_s_desc.

Done.

Thank you - that was just what I was looking for.