[TYPO3-commerce] Filter products by attributes
Sebastian Böttger
sebastian.boettger at gmail.com
Sat Oct 27 11:47:12 CEST 2007
Hi,
I'm just writing an extension to filter products by attributes.
I came across the following problem
http://bugs.typo3.org/view.php?id=6599
Some notes are added.
For search engines or if somebody have the same problem not reading the
bug tracker I post it here again.
Anybody have a solution for this problem?
0006599: get_Articles_by_AttributeArray builds wrong SQL
/**
* returns the list or articles from this product filtered by
given AttributeUID and Attribute Value
* @param attribute_UID
* @param attribute_value
* @return array of article uids
* @TODO handling of valuelists
*/
function get_Articles_by_Attribute($attributeUid,$attributeValue){
return
$this->get_Articles_by_AttributeArray(array(array('AttributeUid'=>$attributeUid,'AttributeValue'=>$attributeValue)));
}
The following code
$attributeUid = 4;
$attributeValues[0] = '3Mio';
$articles[] =
$prodObj->get_Articles_by_Attribute($attributeUid,$attributeValues[$key]);
will result in an empty $articles array, even if there are articles
matching the given attribute/value pair.
Reason: The build SQL isn't correct and will fail:
SELECT DISTINCT tx_commerce_articles.uid
FROM tx_commerce_articles, tx_commerce_articles_article_attributes_mm,
tx_commerce_attributes
WHERE tx_commerce_articles.uid =
tx_commerce_articles_article_attributes_mm.uid_local
AND tx_commerce_attributes.uid =
tx_commerce_articles_article_attributes_mm.uid_foreign
AND ( 0
OR (
tx_commerce_attributes.uid =31
AND tx_commerce_articles_article_attributes_mm.value_char = '3Mio'
)
OR (
tx_commerce_attributes.uid =31
AND tx_commerce_articles_article_attributes_mm.default_value
IN (
3Mio
) )
OR (
tx_commerce_attributes.uid =31
AND tx_commerce_articles_article_attributes_mm.uid_valuelist
IN (
3Mio
)
)
)
AND tx_commerce_articles.hidden =0
AND tx_commerce_articles.deleted =0
AND tx_commerce_articles.uid_product =4
LIMIT 0 , 30
MQSQL error: 0001054 <http://bugs.typo3.org/view.php?id=1054> - Unknown
column '3Mio' in 'where clause'
Regard
Sebastian Böttger
More information about the TYPO3-project-commerce
mailing list