IMHO
I think the complication relies on the logic, not on the HABTM.

Maybe you should look for a workaround, maybe get a fixed discount per
unit (litre, kilo, whatever) which can be stored on the product table.
I wouldn't go for it, but it's a workaround.

Other solution would be to set fixed packages and treat them as
separate products:
product 1: Milk x 1L
product 2: Milk x 2L
each would have its individual cost.
This kind of solution leaves intact the data schema so that you don't
have to count on complex data queries to know/store what you are
selling/pricing.
Edit form will be easier and queries should quite simple.
When the logic on your system is clear enough, database relations
shall bake like a charm.

Again, IMHO. Hope it helps.

On Oct 27, 9:30 pm, kicaj <[email protected]> wrote:
> Yes, but this example it's not for me, listen:
> I have Product with many Package, and Package have 'cost' per Product
> with Package
>
> Explain (product, cost/package):
> 1. Milk cost $1/1l
> 2. Milk cost $1,50/2l
> 3. Coffe cost $2/1l
>
> I have many Product
> I have many Package
> And I have many cost for each Package of Product
>
> I can't write like this:
> Product HABTM Package
> Package hasOne Price (with 'cost' field)
> because different Package have different Price.cost
>
> On Oct 28, 12:55 am, Sergio Silva <[email protected]> wrote:
>
>
>
> > I recommend you this 
> > reading:http://book.cakephp.org/view/85/Saving-Related-Model-Data-HABTM
>
> > When it says "What to do when HABTM becomes complicated?"
>
> > Good luck
>
> > 2009/10/27 kicaj <[email protected]>:
>
> > > I have relations:
>
> > > Products HABTM Package
>
> > > Table 'packages_products' has fields: id, package_id, product_id and
> > > extra field cost (varchar)
>
> > > How build form for this form with select input width packages?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to