VirtueMart Forum

VirtueMart Dev/Coding Central: VM1 (old version) => Development Projects, Modifications, Hacks & Tweaks. VM1.1 => Topic started by: Alex on June 08, 2007, 20:37:54 pm

Title: Product Short Description in Featured Products
Post by: Alex on June 08, 2007, 20:37:54 pm
Hello,

I need the short product description to be shown under the products in the featured products mod. I tried going through the code, and it ends up calling a snapshot function, that dosent have this feature.

any suggestions please?

thank you :)
Title: Re: Product Short Description in Featured Products
Post by: Joseph Kwan on June 08, 2007, 20:54:23 pm
You can
1. cusrtomize the snapshot function or
2. In mod_featureprod.php, replace the first line of the database query with
   $q  = "SELECT DISTINCT product_sku, product_s_desc FROM #__{vm}_product, #__{vm}_product_category_xref, #__{vm}_category WHERE \n";

and print the value of $db->f("product_sku") after each call to the snapshot function.
Joseph
Title: Re: Product Short Description in Featured Products
Post by: Alex on June 11, 2007, 17:41:51 pm
Thank you for the reply

I will eventually try to create my own funciton if this mod works. but im not getting anything showing under the products.

   function show_snapshot($product_sku, $show_price=true, $show_addtocart=true ) {

      echo $this->product_snapshot($product_sku, $show_price, $show_addtocart);

   }
   /**
    * Returns HTML code for a snapshot of a product based on the product sku.
    * This was written to provide a quick way to display a product inside of modules
    *
    * @param string $product_sku The SKU identifying the product
    * @param boolean $show_price Show the product price?
    * @param boolean $show_addtocart Show the add-to-cart link?
    */
   function product_snapshot( $product_sku, $show_price=true, $show_addtocart=true ) {

      global $sess, $VM_LANG, $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 );
      $html = "";
      if ($db->next_record()) {

         $cid = $ps_product_category->get_cid( $db->f("product_id" ) );

         $html .= "<span style=\"font-weight:bold;\">".$db->f("product_name")."</span>\n";
         $html .= "<br />\n";
         
         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");
         }
         $html .= "<a title=\"".$db->f("product_name")."\" href=\"". $sess->url($mm_action_url. "index.php" . $url)."\">";
         $html .= $this->image_tag($db->f("product_thumb_image"), "alt=\"".$db->f("product_name")."\"");
         $html .= "</a><br />\n";
         $html .= $db->f("product_s_desc");  // <----------- MOD HERE.
         
         if (_SHOW_PRICES == '1' && $show_price) {
            // Show price, but without "including X% tax"
            $html .= $this->show_price( $db->f("product_id"), true );
         }
         if (USE_AS_CATALOGUE != 1 && $show_addtocart && !strstr( $html, $VM_LANG->_PHPSHOP_PRODUCT_CALL)) {
            $html .= "<br />\n";
            $url = "?page=shop.cart&func=cartAdd&product_id=" .  $db->f("product_id");
            $html .= "<a title=\"".$VM_LANG->_PHPSHOP_CART_ADD_TO.": ".$db->f("product_name")."\" href=\"". $sess->url($mm_action_url . "index.php" . $url)."\">".$VM_LANG->_PHPSHOP_CART_ADD_TO."</a><br />\n";
         }
      }

      return $html;
   }

You can
1. cusrtomize the snapshot function or
2. In mod_featureprod.php, replace the first line of the database query with
   $q  = "SELECT DISTINCT product_sku, product_s_desc FROM #__{vm}_product, #__{vm}_product_category_xref, #__{vm}_category WHERE \n";

and print the value of $db->f("product_sku") after each call to the snapshot function.
Joseph
Title: Re: Product Short Description in Featured Products
Post by: Joseph Kwan on June 11, 2007, 18:47:30 pm
You forget to modify the Database query to return the value of proudct_s_desc.
Joseph
Title: Re: Product Short Description in Featured Products
Post by: Alex on June 11, 2007, 18:56:11 pm
lol opps, sorry been a few years since i worked with php and mysql. thank you, works perfect :D

You forget to modify the Database query to return the value of proudct_s_desc.
Joseph