Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Virtuemart get product_id

Posted on 2009-07-12
3
Medium Priority
?
2,454 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 1500 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Suggested Courses

971 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