Page 1 of 1

Advice please on handling customization

Posted: Thu Oct 06, 2011 4:05 pm
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?

Re: Advice please on handling customization

Posted: Tue Oct 11, 2011 6:13 pm
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.

Re: Advice please on handling customization

Posted: Sat Oct 29, 2011 2:40 am
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!