Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8167281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:08:51+00:00 2026-06-06T20:08:51+00:00

Hi created a custom model inside Magento(resource is based on Mage_Core_Model_Resource_Db_Collection_Abstract ). Everything works

  • 0

Hi created a custom model inside Magento(resource is based on Mage_Core_Model_Resource_Db_Collection_Abstract ). Everything works pretty much fine.
I tried to make a filter on table, that would output the following where clause:

where
  product_id = 1
  and ((customer_id = 0 and customergroup_id = 2) or (customergroup_id = 0 and customer_id = 3))
  and ((productgroup_id = 0 and product_class = 8) or (product_class = 0 and productgroup_id = 4))

Any idea on how to do that using addFilter or something?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T20:08:52+00:00Added an answer on June 6, 2026 at 8:08 pm

    The addFieldToFilter/addAttributeToFilter methods are not well suited for a query that complex. You will have to construct your query by hand:

    $collection->getSelect()
        ->where('product_id = ?', 1)
        ->where(sprintf(
            '((customer_id = %d AND customergroup_id = %d) OR (customer_id = %d AND customergroup_id = %d))',
            0, 2, 3, 0))
        ->where(sprintf(
            '((productgroup_id = %d AND product_class = %d) OR (productgroup_id = %d AND product_class = %d))',
            0, 8, 4, 0));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created a custom view that uses Json.Simple to serialize the model and write
I've created custom toggle slide animation. Its working fine as expected but its not
I created my own toolbar. Inside toolbar I have collection property to display custom
I have an application that works heavily with many custom objects that are created
I am learning django-cms. I tried to make custom plugin which was quite successful
I'm sure I'm missing something pretty simple here. I've created a custom DateTime display
Is this the only way to create custom model validation? To do it using
I created custom adapter for listview which contain text and images, on click of
I have created custom posts and I want one page in my site to
I have created custom jQuery UI widget called uiPopover, very similar to UI-dialog (in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.