Yes is related to cake, well all I want to know is if there is a
solution to this in cake.
I have Categories like
Array(
[0] => Array(
[Category] => Array(
[id] => 1,
[parent_id] => null,
[name] => 'Parent category 1',
[product_count] => 0
),
[children] => Array(
[0] => Array(
[Category] => Array(
[id] => 2,
[parent_id] => 1,
[name] => 'Subcategory 1',
[product_count] => 5
)
)
)
)
)
Thing is: i can only have products in a subcategory, I want to know if
it's a possibility in cake to obtain in the parent category the number
of products associated to it's subcategories.
What i have is
On Fri, 2009-05-15 at 01:58 -0700, majna wrote:
> Try with find('all') with "joins" , group by, count.. to attach
> product counts.
> see Model::_findThreaded()if it can helps to SUM counts.
>
> Do you think this problem is related to cakephp?
>
>
> On May 15, 8:49 am, "Bogdan I. Bursuc" <[email protected]>
> wrote:
> > I know that, product_count is the counter_cache, but only for the
> > subcategories the ones that have a parent_id from the categories, is a
> > threaded model, and when i select the main categories i want to know the
> > count of the products in all the subcategories :). That's my dilemma.
> >
> > Thx.
> >
> > On Thu, 2009-05-14 at 13:47 -0700, majna wrote:
> > > there is "counter cache" counter_cache property. check manual.
> >
> > > On May 14, 4:41 pm, "Bogdan I. Bursuc" <[email protected]>
> > > wrote:
> > > > I have the following model:
> > > > categories:
> > > > - id,
> > > > - parent_id,
> > > > - name,
> > > > - product_count
> > > > So, the model is threaded: exists main categories and subcategories
> > > > that's it, but only subcategories contain products so only for
> > > > subcategories product_count will be incremented.
> > > > My question:
> > > > Is there a way in cake so that when i do a find on the main
> > > > categories
> > > > to obtain the number of products in all it's subcategories.
> >
> > > > Thx.
> >
> >
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---