cancel
Showing results for 
Search instead for 
Did you mean: 

Property with 2 subproperties

fmberqui
Champ in-the-making
Champ in-the-making
Hello,

I´m having problems trying to extend the model, and I don´t know if it´s possible what I want to do.

I want to make something like a book´s shop, where a book can have some prices that will depend of the usergroup which user belongs to. For example, a book can cost 10 € to a user of group1 and 20 € to a user that belongs to group2 and I need to store this and show it. Too, I will need to take these values via WebServices but first, I need to store them.

Is this possible?

Thank you so much.

Salutes.
6 REPLIES 6

fmontinaro
Champ in-the-making
Champ in-the-making
A simple solution could be to store two or more properties (price_group1, price_group2 ecc..) in your custom type and create a custom webscript that:
- checks current user and his groups
- creates a custom response (json, xml…) with the correct value of property price

I hope this helps you

fmberqui
Champ in-the-making
Champ in-the-making
Thanks for the answer.

The problem is that the groups will be created dinamically, so I need to store so many properties and list so many groups as groups.

I dont think if that is possible…

Salutes.

jpfi
Champ in-the-making
Champ in-the-making
hi,
the easiest solution would be to use a d:text property & store your book prices as json, e.g.
{
default_price: 10,
special_prices:[
{
  group: "group1",
  price : 5
},
{
  group: "group2",
  price : 15
}
]

}

it's dirty, but if you don't like to query this property it is a common workaround.
Cheers, jan

fmberqui
Champ in-the-making
Champ in-the-making
You mean store it on xml model?

mrogers
Star Contributor
Star Contributor
No its stored as text containing JSON.   As Jan says above its dirty.

An alternative way to do it would be a "price" object.  So each book could have a collection of prices.      That may or may not fit your requirement better.

fmberqui
Champ in-the-making
Champ in-the-making
Objects sounds good, but I´m new developing on Alfresco, can you give me some link where explain how to create objects? I suppose that they will be something like a bean where specific some properties, right?

Thank you so much for all the answers.

Salutes.