Frage

I have a create attribute called acloth'size for product and I have enabled the Use In Search Results Layered Navigation option in the backend. So while doing search, I am getting MySQL error

a:5:{i:0;s:1106:"SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''size_idx.entity_id) AS `count` FROM `catalog_product_entity` AS `e`
 INNER JOIN' at line 1, query was: SELECT `acloth'size_idx`.`value`, COUNT(acloth'size_idx.entity_id) AS `count` FROM `catalog_product_entity` AS `e`
 INNER JOIN `catalogsearch_result` AS `search_result` ON search_result.product_id=e.entity_id AND search_result.query_id='26'

I am getting the error of the product attribute field name. Is there any way to allow the apostrophe (') in search for the product attribute.

War es hilfreich?

Lösung

Looks like the database field name is not quoted in all queries by Magento. In this case

COUNT(acloth'size_idx.entity_id)

should have been

COUNT(`acloth'size_idx`.entity_id)

You would have to find the core file where this "count" is generated to fix this specific issue, but there might be many more.

The only reasonable solution I see is to not use any kinds of quotes in attribute codes.

Andere Tipps

You need to use this:

echo $this->escapeHtml($_product->getName())

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit magento.stackexchange
scroll top