Smile-SA / magento2-module-custom-entity-product-link

31 stars 12 forks source link

Admin global search and filters not working #22

Open adimilea opened 5 years ago

adimilea commented 5 years ago

Hi,

Thank you for the code you've shared with us all.

I'm not sure if this is a working release or not. But on a clean M2.3.1 install with ElasticSuite and CustomEntity modules added - the CustomEntityProductLink has some errors on the admin side.

I added a "brand" custom entity and set it up as a product attribute. All works well, but when you try the global search in admin, it errors out like this:

main.ERROR: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'brand' in 'where clause', query was: SELECT COUNT(DISTINCT e.entity_id) FROM `catalog_product_entity` AS `e` WHERE (`e`.`entity_id` IN(SELECT `catalog_product_entity`.`entity_id` FROM `catalog_product_entity` WHERE (`brand` LIKE '%test%') UNION ALL SELECT `catalog_product_entity`.`entity_id` FROM `catalog_product_entity` WHERE (`sku` LIKE '%test%') UNION ALL SELECT `t1`.`entity_id` FROM `catalog_product_entity_text` AS `t1`
 LEFT JOIN `catalog_product_entity_text` AS `t2` ON t1.entity_id = t2.entity_id AND t1.attribute_id = t2.attribute_id WHERE (t1.attribute_id IN ('75', '76')) AND (t1.store_id = 0) AND (IFNULL(t2.value, t1.value) LIKE '%test%') UNION ALL SELECT `t1`.`entity_id` FROM `catalog_product_entity_varchar` AS `t1`
 LEFT JOIN `catalog_product_entity_varchar` AS `t2` ON t1.entity_id = t2.entity_id AND t1.attribute_id = t2.attribute_id WHERE (t1.attribute_id IN ('73', '154')) AND (t1.store_id = 0) AND (IFNULL(t2.value, t1.value) LIKE '%test%')))

Obviously, this part is not valid as there is no 'brand' column in the catalog_product_entity db table:

SELECTcatalog_product_entity.entity_idFROMcatalog_product_entityWHERE (brandLIKE '%test%')

Also, if you set the custom entity product attribute to be filterable in grid - it will also error out like the above.

I suppose there are filters added to the search collection - can you point me the right direction to where I should look for these?

Thanks again!

Adrian.

delyriand commented 4 years ago

Hello @adimilea,

It's a mistake. We did not updated the sql search queries when we have a custom entity product attribute.

But a fix has just been merged (#23) and we have just created a new release. Can you try with the version 1.1.1?

For the filters in the BO, we are working to fix it as soon as possible

13daemon commented 1 year ago

Hi, are the admin product grid filters fixed at the present moment? I see they still don't work (M2.4.5, module-custom-entity 1.3.9, module-custom-entity-product-link 1.3.8).

Also, the entity's name is always empty in admin product grid, when the product's "custom entity" attribute has "Add to Column Options" flag set.