Solved

Virtuemart get product_id

Posted on 2009-07-12
3
2,335 Views
Last Modified: 2012-06-21
Hi there,

I need to access the product_id of each product that is listed in the following Virtuemart store page:

http://lovemyself.com.au/index.php?option=com_wrapper&view=wrapper&Itemid=61

Each item is created by the the file at:

\components\com_virtuemart\themes\default\templates\browse\browse2.php

But I cannot find anywhere in the entire site source code that lets me access the product_id variable for each product.

I can see that in browse2.php there are various variables used, such as $product_name, $product_s_desc, $product_flypage etc, but $product_id does not work.   The $product_flypage is the variable that builds the link for the product detail page - so I know the ID is within that $product_flypage variable, but I need it isolated.

I can access the ID from the URL after I view the product detail page by using a GET command. For example - http://lovemyself.com.au/index.php?page=shop.product_details&flypage=flypage.tpl&product_id=48&category_id=6&option=com_virtuemart&&Itemid=63  (the product_id is 6).  But that method obvioulsy doesn't work back on the browse page.

Any help would be greatly appreciated!
0
Comment
Question by:webstudiointeractive
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
Adam Chan earned 500 total points
ID: 24837136
Greetings,

I'm not entirely sure if this is what you're looking for but from a preliminary look at the source code of the page shows that the actual listing of the products in the browse page is within an iframe:

<div class="contentpane">
<iframe       id="blockrandom"
...
src="http://lovemyself.com.au/index.php?option=com_virtuemart&Itemid=62&category_id=6&page=shop.browse&limitstart=0&limit=500"
...


There are the links/images of each product, and you can extract the product_id from the hyperlink.

Cheers
0
 

Author Comment

by:webstudiointeractive
ID: 24837174
Hi addamez.  Thanks for that.  Yes I'm aware of the iframe, and that the product_id is in the hyperlink.  How would I extract the product ID from a hyperlink using PHP?  That would work...

Obviously I can't use the GET command, as this is a hyperlink within the body of the site.  Is there a PHP method to trim the link so that I'm left with the ID?  For example, it returns everything after "product_id=" and everything before the next ampersand "&" ?

0
 

Author Comment

by:webstudiointeractive
ID: 24837336
Worked it out by using the following code. I'm sure there's a simpler way to do it with PHP but this worked so I'll run with that!
<? $var1 = explode("&", $product_flypage); $var2 = explode("=", $var1[2]); echo $var2[1]; ?>

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now