Forums / Developer / AttributeFilter not worked in PHP Code

AttributeFilter not worked in PHP Code

Author Message

Issam Mouzoun

Thursday 12 February 2009 7:40:33 am

Hi everyone,

I made this code for fetching product, but AttributeFilter doesn't take on consideration the condition :

$normeParamsSearch = array (
'ClassFilterType' => 'include',
'ClassFilterArray' => array ('product'),
'AttributeFilter' => array( array('referencenorme','=', 'NM2344' ) ),
'Limit' => 1,
'Depth' => 1
);
//echo $boutiqueNodeId;
$normesList =

eZContentObjectTreeNode::subTreeByNodeID($normeParamsSearch, $boutiqueNodeId);

thank u very well

André R.

Thursday 12 February 2009 7:50:57 am

You are missing the class identifier in "referencenorme", see here under "Attribute filtering":
http://ez.no/doc/ez_publish/technical_manual/4_0/reference/modules/content/fetch_functions/list#eztoc87605_0_0_1

From the examples:

{fetch( 'content',
        'list',
        hash( 'parent_node_id',   42,
              'attribute_filter', array( array( 'article/image',
                                        '=',
                                        87 ) ) ) )}

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Issam Mouzoun

Thursday 12 February 2009 9:49:08 am

Hi André

Finally it works, i add class identifier to<b>AttributeFilter</b>, i add "strtolower" to the searched string else the fetch return any result.

$normeParamsSearch = array (
									'ClassFilterType'	=> 'include',
									'ClassFilterArray'	=> array ('product'),
									'AttributeFilter'	=> array( array('product/referencenorme','=', utf8_encode(trim(strtolower("MyString"))) ) ),
									'Limit'	=> 1,
									'Depth'	=> 1
								);
							$normesList = eZContentObjectTreeNode::subTreeByNodeID($normeParamsSearch, $boutiqueNodeId);
 

Thank u very well