News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

product sku on the url

Started by elgiga, July 10, 2012, 00:53:13 AM

Previous topic - Next topic

elgiga

is there a way to make the VM2 work by finding the product even by the product sku on the URL like for example

index.php?option=com_virtuemart&view=productdetails&product_sku=xxxx

ivus

Hi elgiga,

It is possible, however you'll need to create a new view (and controller and model) to process the request.

In the products details controller (/components/com_virtuemart/controllers/productdetails.php)

MODIFY THIS

   function display () {
     
      $sku = JRequest::getVar('sku');
      $format = JRequest::getWord ('format', 'html');
     
      if ($format == 'pdf') {
         $viewName = 'Pdf';
      } else {
         $viewName = 'Productdetails';
      }
     
      if ($sku) {
         $view = $this->getView ('Sku', $format);
      } else {
         $view = $this->getView ($viewName, $format);
      };
      $view->display ();
     
   }



create a new folder under view called sku (/components/com_virtuemart/views/sku/view.html.php) and paste this piece of code into it.



<?php
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');


// Load the view framework
if(!class_exists('VmView'))require(JPATH_VM_SITE.DS.'helpers'.DS.'vmview.php');


class VirtuemartViewSku extends VmView {


   function display($tpl = null) {
      
      echo 'hello world';


   }


}




This will get you started, but obviously you'll still need to create the controller and model to process the rest, but it is achievable. Whether you want the hassle is a different story. Good luck.


I hope this helps.