0

I'm writing a plugin to display products (my first plugin). I have a 10.000 product database with ids, names, images, description. I can display all of them from a page template/dummy page. How can I make every product have its own page where description and other attributes are listed? Similar manner as choosing a post from a list of posts, but for individual products?

EDIT: I just made:

if(isset($_GET['product'])){
        include('includes/product.php');
}

if(isset($_GET['category'])){
    include('includes/category.php');
}

if(!isset($_GET['category']) && !isset($_GET['product'])){
    include('includes/catalog.php');
}

How bad is it?

1 Answer 1

0

I did this for a mock movie DB in school. You can have each product their own unique ID, and upon clicking it, have it open in a generic page based on the ID, and find everything identifying with it matching that ID.

So if a customer clicks a product, such as shampoo, with an ID of 3076, then it will pull up anything with 3076 associated.

Just pass this information from the listing page to the "Designated" page, and it should upload just fine. :)

All products have to share the same column names, so it all has to be local to one database table. This is the only exception.

By having one "upload" page, you save so much memory. It just takes the passed ID... it will not mater if it's 3076, or 9999. It'll always work.

2
  • I was concerned more about doing it correctly as a plugin. Similar like commerce plugins allow to select a certain product page from a list. I made a custom plugin to house my if's of every state I expect doc to be Jul 19, 2016 at 12:07
  • Oh! @JessicaGonzalez, I forgot this was a plugin when you create this. Hmm.... I know with form creation plugins, they had a unique tag like [formid=100] on the page, and it'd upload. You could create a similar thing when a product is clicked on, it'll append / replace the nesting value? [productId=N] where N is replaced by the value? Have your PHP call it when this is detected, maybe?
    – MJV
    Jul 19, 2016 at 12:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.