Magento 2: How to add multiple AND conditions to one single attribute that could be used to join other condition groups?How to use FIND_IN_SET on a multiselect attribute filter with an AND condition?Adding attribute using JOIN to CollectionMagento 2: Product Repositories, Filter Groups, and `AND`Assign Multiple Filter to Single FilterGroup in magento 2Magento 2: addAttributeToFilter not returning any resultsMagento : Filter Collection by Attribute that Doesn't Exist or Null or another conditionMagento2: How to add multiple AND and OR conditions to filter/filterGroups?Magento 2 : how to addCategoriesFilter with AND condtion?Magento 1.9 collection multi conditionsMagento 2.3 custom conditions for attribute filter using addAttributeToFilter

Why can't I use =default for default ctors with a member initializer list

What speaks against investing in precious metals?

Wooden cooking layout

Is it possible to have a wealthy country without a middle class?

Has there been a multiethnic Star Trek character?

A IP can traceroute to it, but can not ping

Is this use of the expression "long past" correct?

SQL counting distinct over partition

Which languages would be most useful in Europe at the end of the 19th century?

Arriving at the same result with the opposite hypotheses

Is it legal for a bar bouncer to confiscate a fake ID

How is John Wick 3 a 15 certificate?

How can I get an unreasonable manager to approve time off?

How to communicate to my GM that not being allowed to use stealth isn't fun for me?

How can I make some of my chapters "come to life"?

Is White controlling this game?

Someone whose aspirations exceed abilities or means

Generate basis elements of the Steenrod algebra

What is the maximum number of net attacks that one can make in a round?

Certain search in list

Extreme flexible working hours: how to control people and activities?

Fixing obscure 8080 emulator bug?

How to use memset in c++?

Soft question: Examples where lack of mathematical rigour cause security breaches?



Magento 2: How to add multiple AND conditions to one single attribute that could be used to join other condition groups?


How to use FIND_IN_SET on a multiselect attribute filter with an AND condition?Adding attribute using JOIN to CollectionMagento 2: Product Repositories, Filter Groups, and `AND`Assign Multiple Filter to Single FilterGroup in magento 2Magento 2: addAttributeToFilter not returning any resultsMagento : Filter Collection by Attribute that Doesn't Exist or Null or another conditionMagento2: How to add multiple AND and OR conditions to filter/filterGroups?Magento 2 : how to addCategoriesFilter with AND condtion?Magento 1.9 collection multi conditionsMagento 2.3 custom conditions for attribute filter using addAttributeToFilter






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I could filter a product collection by (attribute A: condition A OR condition B) AND (attribute B: condition C OR condition D) with the following codes:



$collection->addAttributeToFilter('attribute A', [
[condition here...], //e.g. ['neq' => 'x']
[condition here...] //e.g. ['gt' => 'y']
]);
$collection->addAttributeToFilter('attribute B', [
[condition here...],
[condition here...]
]);


But I have no idea how to achieve this:
(attribute A: condition A AND condition B) OR (attribute B: condition C and condition D)



I have also tried to use search criteria builder, but still no luck so far.










share|improve this question
























  • Try like: $collection->addAttributeToFilter('attribute A', [ [condition here... , condition here...], ]);

    – fmsthird
    May 31 at 7:50











  • @magefms The conditions A and B I want would be something like ['gt' => 'xxx'] and ['neq' => 'yyy']. The syntax you provided seems not working.

    – d.yuk
    May 31 at 8:45











  • why not try like $collection->addAttributeToFilter('attribute A', [ [condition here...] ]); $collection->addAttributeToFilter('attribute A', [ [condition here number 2...] ]);

    – fmsthird
    May 31 at 8:49











  • creating two filter for the same attribute that might work

    – fmsthird
    May 31 at 8:49











  • can you try like $collection->addAttributeToFilter( array( array(array('attribute' => 'attribute A', 'neq' => 'x'), array('attribute' => 'attribute A', 'gt' => 'y')), array(array('attribute' => 'attribute B', 'neq' => 'x'), array('attribute' => 'attribute B', 'neq' => 'x')) ) );

    – fmsthird
    May 31 at 9:12

















1















I could filter a product collection by (attribute A: condition A OR condition B) AND (attribute B: condition C OR condition D) with the following codes:



$collection->addAttributeToFilter('attribute A', [
[condition here...], //e.g. ['neq' => 'x']
[condition here...] //e.g. ['gt' => 'y']
]);
$collection->addAttributeToFilter('attribute B', [
[condition here...],
[condition here...]
]);


But I have no idea how to achieve this:
(attribute A: condition A AND condition B) OR (attribute B: condition C and condition D)



I have also tried to use search criteria builder, but still no luck so far.










share|improve this question
























  • Try like: $collection->addAttributeToFilter('attribute A', [ [condition here... , condition here...], ]);

    – fmsthird
    May 31 at 7:50











  • @magefms The conditions A and B I want would be something like ['gt' => 'xxx'] and ['neq' => 'yyy']. The syntax you provided seems not working.

    – d.yuk
    May 31 at 8:45











  • why not try like $collection->addAttributeToFilter('attribute A', [ [condition here...] ]); $collection->addAttributeToFilter('attribute A', [ [condition here number 2...] ]);

    – fmsthird
    May 31 at 8:49











  • creating two filter for the same attribute that might work

    – fmsthird
    May 31 at 8:49











  • can you try like $collection->addAttributeToFilter( array( array(array('attribute' => 'attribute A', 'neq' => 'x'), array('attribute' => 'attribute A', 'gt' => 'y')), array(array('attribute' => 'attribute B', 'neq' => 'x'), array('attribute' => 'attribute B', 'neq' => 'x')) ) );

    – fmsthird
    May 31 at 9:12













1












1








1








I could filter a product collection by (attribute A: condition A OR condition B) AND (attribute B: condition C OR condition D) with the following codes:



$collection->addAttributeToFilter('attribute A', [
[condition here...], //e.g. ['neq' => 'x']
[condition here...] //e.g. ['gt' => 'y']
]);
$collection->addAttributeToFilter('attribute B', [
[condition here...],
[condition here...]
]);


But I have no idea how to achieve this:
(attribute A: condition A AND condition B) OR (attribute B: condition C and condition D)



I have also tried to use search criteria builder, but still no luck so far.










share|improve this question
















I could filter a product collection by (attribute A: condition A OR condition B) AND (attribute B: condition C OR condition D) with the following codes:



$collection->addAttributeToFilter('attribute A', [
[condition here...], //e.g. ['neq' => 'x']
[condition here...] //e.g. ['gt' => 'y']
]);
$collection->addAttributeToFilter('attribute B', [
[condition here...],
[condition here...]
]);


But I have no idea how to achieve this:
(attribute A: condition A AND condition B) OR (attribute B: condition C and condition D)



I have also tried to use search criteria builder, but still no luck so far.







magento2 product-collection eav-attributes






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited May 31 at 8:46







d.yuk

















asked May 31 at 7:28









d.yukd.yuk

247212




247212












  • Try like: $collection->addAttributeToFilter('attribute A', [ [condition here... , condition here...], ]);

    – fmsthird
    May 31 at 7:50











  • @magefms The conditions A and B I want would be something like ['gt' => 'xxx'] and ['neq' => 'yyy']. The syntax you provided seems not working.

    – d.yuk
    May 31 at 8:45











  • why not try like $collection->addAttributeToFilter('attribute A', [ [condition here...] ]); $collection->addAttributeToFilter('attribute A', [ [condition here number 2...] ]);

    – fmsthird
    May 31 at 8:49











  • creating two filter for the same attribute that might work

    – fmsthird
    May 31 at 8:49











  • can you try like $collection->addAttributeToFilter( array( array(array('attribute' => 'attribute A', 'neq' => 'x'), array('attribute' => 'attribute A', 'gt' => 'y')), array(array('attribute' => 'attribute B', 'neq' => 'x'), array('attribute' => 'attribute B', 'neq' => 'x')) ) );

    – fmsthird
    May 31 at 9:12

















  • Try like: $collection->addAttributeToFilter('attribute A', [ [condition here... , condition here...], ]);

    – fmsthird
    May 31 at 7:50











  • @magefms The conditions A and B I want would be something like ['gt' => 'xxx'] and ['neq' => 'yyy']. The syntax you provided seems not working.

    – d.yuk
    May 31 at 8:45











  • why not try like $collection->addAttributeToFilter('attribute A', [ [condition here...] ]); $collection->addAttributeToFilter('attribute A', [ [condition here number 2...] ]);

    – fmsthird
    May 31 at 8:49











  • creating two filter for the same attribute that might work

    – fmsthird
    May 31 at 8:49











  • can you try like $collection->addAttributeToFilter( array( array(array('attribute' => 'attribute A', 'neq' => 'x'), array('attribute' => 'attribute A', 'gt' => 'y')), array(array('attribute' => 'attribute B', 'neq' => 'x'), array('attribute' => 'attribute B', 'neq' => 'x')) ) );

    – fmsthird
    May 31 at 9:12
















Try like: $collection->addAttributeToFilter('attribute A', [ [condition here... , condition here...], ]);

– fmsthird
May 31 at 7:50





Try like: $collection->addAttributeToFilter('attribute A', [ [condition here... , condition here...], ]);

– fmsthird
May 31 at 7:50













@magefms The conditions A and B I want would be something like ['gt' => 'xxx'] and ['neq' => 'yyy']. The syntax you provided seems not working.

– d.yuk
May 31 at 8:45





@magefms The conditions A and B I want would be something like ['gt' => 'xxx'] and ['neq' => 'yyy']. The syntax you provided seems not working.

– d.yuk
May 31 at 8:45













why not try like $collection->addAttributeToFilter('attribute A', [ [condition here...] ]); $collection->addAttributeToFilter('attribute A', [ [condition here number 2...] ]);

– fmsthird
May 31 at 8:49





why not try like $collection->addAttributeToFilter('attribute A', [ [condition here...] ]); $collection->addAttributeToFilter('attribute A', [ [condition here number 2...] ]);

– fmsthird
May 31 at 8:49













creating two filter for the same attribute that might work

– fmsthird
May 31 at 8:49





creating two filter for the same attribute that might work

– fmsthird
May 31 at 8:49













can you try like $collection->addAttributeToFilter( array( array(array('attribute' => 'attribute A', 'neq' => 'x'), array('attribute' => 'attribute A', 'gt' => 'y')), array(array('attribute' => 'attribute B', 'neq' => 'x'), array('attribute' => 'attribute B', 'neq' => 'x')) ) );

– fmsthird
May 31 at 9:12





can you try like $collection->addAttributeToFilter( array( array(array('attribute' => 'attribute A', 'neq' => 'x'), array('attribute' => 'attribute A', 'gt' => 'y')), array(array('attribute' => 'attribute B', 'neq' => 'x'), array('attribute' => 'attribute B', 'neq' => 'x')) ) );

– fmsthird
May 31 at 9:12










0






active

oldest

votes












Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f276825%2fmagento-2-how-to-add-multiple-and-conditions-to-one-single-attribute-that-could%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Magento Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f276825%2fmagento-2-how-to-add-multiple-and-conditions-to-one-single-attribute-that-could%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?