I'm attempting to extract the 'category_id' information from each product. Here's my type of thought:

What I am attempting to do...

I sell music items. An Album consists of 10 Tracks. Rather than making each Track a young child from the Album (I have carried this out for any reason, do not suggest this like a solution), I made the Album and every separate Track a person product. I have linked all Tracks towards the Album by putting the Album ID within the "Extra IDs" area of every Track, and I have put each each Track ID within the "Extra IDs" area from the Album.

  • Piano Album 1
    -> Track 1
    -> etc.

To differentiate the only tracks in the full album, I have produced a category known as "Single", we'll just the 'category_id' is 23. Additionally for this distinction, all items will also be categorized through the instrument the song is performed in. Again, for argument's sake we'll say "Piano" is equivalent to 'category_id' number 5.

Now, in layman, after i click the category "Piano" I'll get a listing of listing of items which are within the "Piano" category. Let us say:

  • Piano Album 1
  • Piano Album 2
  • Piano Track 1

But, after i click "Piano Track 1", I would like it to take me towards the flypage of "Piano Album 1" rather than its very own flypage.

The idea for my option would be...

Within the .../components/com_virtuemart/styles/default/templates/browse/browse-lite.php file, I'll grab the URL or $product_flypage, as it is known to here, and grab the 'product_id', like so:

/* Strip the Product Id from the array of the URL */
$temp_arr = explode ("amp;",$product_flypage);
$temp_prod_id = $temp_arr[2];//Example: product_id=551&
$trim_prod_id1 = strrchr($temp_prod_id,'=');
$trim_prod_id2 = trim($trim_prod_id1,"=");
$temp_prod_id2 = trim($trim_prod_id2,"&");
echo $temp_prod_id2; //Example: 551

Next, Let me lookup the 'category_id's for your 'product_id', and perhaps load them into an assortment??

Then, determine if the 'category_id's match up with number 23, "Single".

If true then I have to to exchange the 'product_id' using the Album ID (I'm able to do that part), and when false, just leave the $product_flypage alone.

The issue is...

I'm not sure enough PHP or MySql to effectively pull this off.

Can anybody help? Any help could be appreciated.