News:

Support the VirtueMart project and become a member

Main Menu

VM 3.0.16 show product id in a browse page

Started by Micha70, April 26, 2016, 18:54:36 PM

Previous topic - Next topic

Micha70

Hello,

i have a own view like the view productdetails. Both are overridden and a link of the startpage to my external view default.php which open in a fancybox.
The link to the new view page is:
$mylink = JRoute::_index.php?option=com_virtuemart&view=myproddetailview&virtuemart_product_id= '.$product->virtuemart_product_id. &'virtuemart_categorie_id='.$product->virruemart_categorie_id='.$product->virtuemart_categorie_id&'tmpl=component', FALSE);

But the product id is not the same as the product which is visible in the link. It is a random or  the last product from related products.

Is there any solution for the newest Virtuemart 3.0.16 like this question too?: http://forum.virtuemart.net/index.php?topic=72033.0

My PHP Version is 5.6.14 and Joomla 3.4.8.

greets
Michael

Ghost

Did you copy/paste this link from your site or just wrote it for this post? Because it has errors. Should be like this:

$mylink = JRoute::_('index.php?option=com_virtuemart&view=myproddetailview&virtuemart_product_id='.$product->virtuemart_product_id.'&virtuemart_category_id='.$product->virtuemart_categoy_id.'&tmpl=component', FALSE);

Micha70

Hello Ghost,

thank you for your tip. I'm sorry. But i can't paste it in this editor, i had write it, with my smartphone too. The $mylink is functionally ok. Only the product_id not the right by calling the browse page.
In the other question at the link in my first post is an answer about the prodict_id to be added to an url which give it to an external browse page. I can't find the right file and tests with Sessions lost the right product  :(

Micha70

#3
Ok. I could solved this problem..  :) :o
with $_COOKIE's. Normal $Sessions doesn't available across my sites, but cookies do it.
With onclick="setcookie(my_cookie, cProdPath, cProdName,  cProdPrice, cProdID, cimg, expiredays, ....) i send my variables to the fancybox, wich open my own product detail page.


In the fancybox set the function for the handing over to cross page:

<script type="text/javascript">
function setCookie(cname, cProdPath, cProdName, cProdPrice, cProdID, cimg, expiredays)
{
.....
document.cookie=cname+ "=" + "," + escape(cProdPath)  + "," +  escape(cProdPrice)


I split the document.cookie string manually bevor handing over with a commata.
Then i can in my own product detail page recall the values with index:

$cookie = explode(",", $_COOKIE['my_cookie']);
$i=0;
$myProduct = array('Prod');

foreach($cookie as $index => $val)
{
    $i ++;
    $k = explode(",", $val);
    $myProduct['Prod'][$i] = trim($k[0]);        
}
   echo 'Name: '  .$myProduct['Prod'][2]; // cProdName
   echo 'Price: ' .$myProduct['Prod'][3]; // cProdPrice
   echo 'ID: ' .$myProduct['Prod'][4];    // cProdID


That works fine. The only one problem is, if i change the setcookie parameters, i must change every  index from $myProduct['Prod'][$i]  ::) :'(
Certainly it gives a solution for this...like getElementByID or something like that. But first tests doesn't work with index iteration and the long time to solved this normally minimal problem..? ..was now to long for more tests.

Greets  :)
Micha

PRO

Quote from: Micha70 on April 26, 2016, 18:54:36 PM
i have a own view like the view productdetails.

do you also use the productdetails   view?

if not, why didnt you just create the changes in the productdetails view


OR: if you are using both your view & product details view. You could just add a parameter to the regular product link, and modify the productdetails view based on that

Micha70

#5
Yes, i use the normal product detail view for the startpage products. Click on details from an product opens the original product detail view.

I have an extra short buy button on startpage which open a fancybox with my own product view. Another solution i didnt knew. I am not so fit in programming and the structure from virtuemart also new for me.

A Problem btw is, that the global variables $_Server['REQUEST_URI'] and $_Server['QUERY_STRING'] g ives me only the last product from 'last visited products. DWhen i deactivate the view of this category then the requests give me the highest product id from the 'newest products' ..and so on.. :-\

PRO

Quote from: Micha70 on May 19, 2016, 14:44:23 PM

A Problem btw is, that the global variables $_Server['REQUEST_URI'] and $_Server['QUERY_STRING'] g ives me only the last product from 'last visited products. DWhen i deactivate the view of this category then the requests give me the highest product id from the 'newest products' ..and so on.. :-\

you wouldnt have this problem if you used a modified productdetails view.

whats the purpose of your new view?


Micha70

#7
Thats not right. I have copied the original productdetails view.

independently i tested, just now again the original view. And i became and become the for my purpose false id back. With the original productdetails view equally.

The fancybox doesn't work correct with $productlink = JRoute::_ ('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $product->virtuemart_product_id . '&virtuemart_category_id=' . $product->virtuemart_category_id . $ItemidStr);

I must give the url parameters at other way. Otherwise the product id lost and an id from a featured category is unintentional show.

When i call the normally product details default.php in the browser, then it works both fine! But how i say everytime, not with the fancybox.. :-\

PRO

Quote from: Micha70 on May 19, 2016, 15:31:08 PM
Thats not right. I have copied the original productdetails view.

independently i tested, just now again the original view. And i became and become the for my purpose false id back. With the original productdetails view equally.

The fancybox doesn't work correct with $productlink = JRoute::_ ('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $product->virtuemart_product_id . '&virtuemart_category_id=' . $product->virtuemart_category_id . $ItemidStr);

I must give the url parameters at other way. Otherwise the product id lost and an id from a featured category is unintentional show.

When i call the normally product details default.php in the browser, then it works both fine! But how i say everytime, not with the fancybox.. :-\


fancybox should use the   "component" template, which does not have menus, etc.

Micha70

Thats absolut ok for me. I doesn't need any menus in the fancybox. I found the argument for use it and had to specify this in the product string with 'tmpl=component'.
This is my productdetail link:
$mylink = JRoute::_index.php?option=com_virtuemart&view=myproddetailview&virtuemart_product_id= '.$product->virtuemart_product_id. &'virtuemart_categorie_id='.$product->virruemart_categorie_id='.$product->virtuemart_categorie_id&'tmpl=component', FALSE);

Studio 42

Your link is totally wrong !
virtuemart_categorie_id > virtuemart_category_id
virruemart_categorie_id "virruemart" ???
myproddetailview  is productdetails
If you use your own view then VM cannot set SEF urls.
If you don't use core field name, you cannot set the right value...

$productlink = JRoute::_ ('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $product->virtuemart_product_id . '&virtuemart_category_id=' . $product->virtuemart_category_id . $ItemidStr);
Why $ItemidStr ?
If you use a link inside product details, the correct link is perhaps not $product->virtuemart_product_id but $this->product->virtuemart_product_id

Micha70

#11
Sry, thats a  bad spelling mistake! :-[
I said it already: both productdetail links works great by calling the detail page (default.php..) in a browser!
With $this->product it doesn't work.

This is the original virtuemart link with ItemidStr. I believe the ItemidStr is for Multivendor/Multitemplate?:
$productlink = JRoute::_ ('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $product->virtuemart_product_id . '&virtuemart_category_id=' . $product->virtuemart_category_id . $ItemidStr);

And this my own:
$mylink= JRoute::_index.php?option=com_virtuemart&view=myproddetailview&virtuemart_product_id= '.$product->virtuemart_product_id. &'virtuemart_categorie_id='.$product->virtuemart_categorie_id='.$product->virtuemart_categorie_id&'tmpl=component', FALSE);

I tested both, with and without the ItemidStr. He does not harm, no values was changed or fired an error.
I think its a fancybox configuration in virtuemart or a vm configuration in file, that  discards the user call. It's not standard to use the fancybox to show products or productdetails.