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

  • SEARCH
  • Home
  • 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 6823579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:47:56+00:00 2026-05-26T21:47:56+00:00

I have an attribute defined for a product that will contain a comma separated

  • 0

I have an attribute defined for a product that will contain a comma separated list of values. The idea behind this is so that I can cross reference this product against another product.

pseudo code would look a little like this:
Find all products where the attribute “cross_ref” is like ‘%1234%’

The cross_ref attribute will contain something like “1234,5678,abcd” etc
I’ve tried the following but it doesn’t return any products:

$collection = Mage::getModel('catalog/product')->getCollection();
$collection->addAttributeToSelect('*');
$collection->addFieldToFilter('cross_ref',array('like'=> '1234'));
//$collection->addAttributeToFilter('cross_ref',array('like'=> '1234')); // This didn't work either
foreach ($collection as $product) {
        var_dump($product->getData());
}

This code doesn’t return anything though.

Any ideas how I can achieve this?

Thank you

  • 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-05-26T21:47:57+00:00Added an answer on May 26, 2026 at 9:47 pm

    Looks like you forgot the % sign to match a subpart of the string: 'like' => '%1234%'.

    However, if you don’t want 1234 to match 12345, you might want to include the comma in the query, and also allow for no commas in the beginning or end of the string:

    $collection->addFieldToFilter('cross_ref', array(
        array('like'=> '%,1234,%'),
        array('like'=> '1234,%'),
        array('like'=> '%,1234'),
    ));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have defined a tag with a CSS attribute overflow set to scroll. This
I have a product attribute that I have set the scope to website (so
I have defined a custom Sharepoint list for special attributes related to a software
I have an attribute declared on property. How can I get the property name
I have notes attribute in Product model with text something, something else. In views
I have this attribute in my view model: [CustomRequired, EmailRegex] [Display(Name = KeepInformedPersonMail, ResourceType
I have an old product that I need to update, written in C# and
I have custom attribute defined like so: [AttributeUsage(AttributeTargets.Field)] public class EnumDisplayAttribute : Attribute {
I want to model e-commerce product attributes that can be changed in run-time. So
I have defined attribute is_first for table items. In model Item, i want to

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.