Quantcast

Filter by product properties with paginate...

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Filter by product properties with paginate...

technobulka
In category I show products list with paginate:
var $paginate = array(
    'Product' => array(
        'limit' => 10,
        'order' => array(
            'Product.instock' => 'desc',
            'Product.title' => 'asc',
        ),
    )
);

if user choose filter than I add conditions:
$this->paginate['Product']['contain']['ProductsProperty']['conditions']['OR'] = $contain_conditions;

but this filter don't remove products from list, it remove only products properties and it looks like:
Array
(
    [0] => Array
        (
            [Product] => Array
                (
                    [id] => 42
                    ...
                ) 
 
            [ProductsProperty] => Array
                (
                )
        ) 
(
    [1] => Array
        (
            [Product] => Array
                (
                    [id] => 3
                    ...
                ) 
 
            [ProductsProperty] => Array
                (
                )
        ) 
 
 

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
[hidden email] For more options, visit this group at http://groups.google.com/group/cake-php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Filter by product properties with paginate...

lowpass
That's because contain doesn't create a join. Instead, Cake paginates
the Products, then runs through the result and individually selects
the Properties. WHat you would need to do is use a join. Search google
with:

cakephp paginate intext:"join"

On Wed, Jun 27, 2012 at 2:05 AM, technobulka <[hidden email]> wrote:

> In category I show products list with paginate:
>>
>> var $paginate = array(
>>
>>     'Product' => array(
>>
>>         'limit' => 10,
>>
>>         'order' => array(
>>
>>             'Product.instock' => 'desc',
>>
>>             'Product.title' => 'asc',
>>
>>         ),
>>
>>     )
>>
>> );
>
>
> if user choose filter than I add conditions:
>>
>>
>> $this->paginate['Product']['contain']['ProductsProperty']['conditions']['OR']
>> = $contain_conditions;
>
>
> but this filter don't remove products from list, it remove only products
> properties and it looks like:
>>
>> Array
>>
>> (
>>
>>     [0] => Array
>>
>>         (
>>
>>             [Product] => Array
>>
>>                 (
>>
>>                     [id] => 42
>>
>>                     ...
>>
>>                 )
>>
>>
>>
>>             [ProductsProperty] => Array
>>
>>                 (
>>
>>                 )
>>
>>         )
>>
>> (
>>
>>     [1] => Array
>>
>>         (
>>
>>             [Product] => Array
>>
>>                 (
>>
>>                     [id] => 3
>>
>>                     ...
>>
>>                 )
>>
>>
>>
>>             [ProductsProperty] => Array
>>
>>                 (
>>
>>                 )
>>
>>         )
>
>
>
>
> --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> [hidden email] For more options, visit this group at
> http://groups.google.com/group/cake-php

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
[hidden email] For more options, visit this group at http://groups.google.com/group/cake-php
Loading...