Advice please on handling customization

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
Bel
Forum Newbie
Posts: 6
Joined: Wed Jan 19, 2011 10:04 pm

Advice please on handling customization

Post by Bel »

I have a webapp thats works sort of like a shopping cart (only the products are to build a phone system configuration)

I have a display class that builds product objects and stores them in an array. I then update the product display (amounts, errors etc) then finally display them.

ie:

Code: Select all

$this->items['pcvs300'] = new ItemClass("pcvs300","Polycom Voice Station 300","2200-17900-013");
$this->items['pcvs300']->set_display();
$this->display_handsets .= $this->items['pcvs300']->get_display();

//(i then return $this->display_handsets along with other categories to an ajax response page to build the web app)

I lease this site, it has a couple of dozen reseller accounts now and growing.
Most of these accounts want to see the full product range.
Some want to see that plus unique products to them, others a restricted product range.

My question is how i should impliment that.

I began with the first customized account by
eg:

Code: Select all


    if($_SESSION['user_account'] == "Vodafone"){
        $this->display_handsets = "";
    }
But as more and more customization took place its getting crowded and messy.

So im here asking for advise on how to manage account customization.

Accounts are pulled from a MySQL DB, so im thinking that i could have it also store an array in a field all the products and categories by default, then build the display based on whats in that field.

But any other thoughts?
jraede
Forum Contributor
Posts: 254
Joined: Tue Feb 16, 2010 5:39 pm

Re: Advice please on handling customization

Post by jraede »

If I understood your question correctly, you'd like to have different products available to different reseller accounts. To do that you'd need to create a database table that represents relations between products and resellers...with a column for reseller ID and product ID. Whenever you do a query for products, have it INNER JOIN this new table and on the product ID; that'll weed out any products that don't have a relation with that reseller.

To better explain, say you have reseller Dave and reseller Jeff. Dave wants product X but not Y, and Jeff wants products X and Y. So in your relation table you'd have something like this:

rel_id | rel_reseller | rel_product
------------------------------------------
1 | dave's id | product x's id
------------------------------------------
2 | jeff's id | product x's id
------------------------------------------
3 | jeff's id | product y's id


Then your query for products would look like this:

Code: Select all

SELECT * FROM `products` INNER JOIN `reseller_product_relations` ON `product_id`=`rel_product` WHERE `rel_reseller`='$resellerId'
That's assuming you set $resellerId beforehand.

Hope this helps.
uday8486
Forum Newbie
Posts: 22
Joined: Fri Oct 28, 2011 11:42 pm
Location: Pune, India

Re: Advice please on handling customization

Post by uday8486 »

You can have a user access type, or a role for reseller which you can fetch and according update your display by fetching only that data which is permitted to him, here you also need to define what is accessible and what is not!
Post Reply