php - How to check attributes belongs to specific product in opencart -


I'm trying to find products that have a multiplier specific attribute, I mean, I search for those products I want to have "type" = rings and "metal" = gold

I tried with the operator IN , but this is the option of or operation. I need more operations.

The product_attribute table only contains product_id, attribute_id, how do I do and how it works in mysql

OpenCart version 1.5.4

I 'below Have tried the given question

  SELECT * fROM oc_product_attribute WHERE product_id = 42 and attribute_id = 15 and attribute_id = 17   

Output is empty

If you want a OR argument between attributes in the same group and AND / Li>

  • function which You have to edit, that is public function getProducts ($ data = array), $ get_all = FALSE) {

  • specified at the beginning of the function From the variable: $ validimi = false; $ Filter_groups = array ();

  • Find this code:

      if (! $ Data ['filter_filter']) {$ Implode = array $ Filter = explosion (',', $ data ['filter_filter']); Forex ($ filter $ $ filter_id) {$ implode [] = (int) $ filter_id;} $ Sql. = " AND pf.filter_id IN ("Implode (',', $ implode).");   

    }

  • and < Code> $ sql. = "And pf.filter_id IN (". ',', $ Implode). ");

      $ sql_check =" Distance from Select (filter_group_id) From ".db_prefix" filter WHERE filter_id IN (".implode (',', $ implode).); $ Query_check = $ this- & gt; db- & gt; query ($ sql_check); $ Filter_groups = array (); Foreign Exchange ($ query_check- & gt; Lines $ par As a result {$ filter_groups [$ result ['filter_group_id']] = array ();} if (counting ($ filter_groups)> 1) {$ validimi = true;} and {$ validimi = false;}  
  • Finally, I find this piece of code in the specified function:

    $ sql. = "P.product_id by group";

  • And change it to:

      if ($ validimi) {  

    $ sql = "Group by P. Product_ide Having COUNT (Distinct PF.filter_id) =". Calculation ($ filter_group);

     } Other {$ sql. = "Group byproduct_id"; Now try your filter that they should work fine, this is what I created and used on our own stores but the OpenCart version 1.5.5.1 But I think this will work well in your case. The logic is obvious so if this code does not help you, then you can use logic to create your own :)  

    Hope I helped.

  • Comments

    Popular posts from this blog

    Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

    multithreading - PhantomJS-Node in a for Loop -

    c++ - MATLAB .m file to .mex file using Matlab Compiler -