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 1039291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:04:53+00:00 2026-05-16T15:04:53+00:00

I have created custom attributes for a category in my module’s install script like

  • 0

I have created custom attributes for a category in my module’s install script like so:

$attrib = array(
        'type'          => 'varchar',
        'group'         => 'My Data',
        'backend'       => '',
        'frontend'      => '',
        'label'         => 'My Custom Field',
        'input'         => 'text',
        'class'         => '',
        'source'        => '',
        'global'        => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
        'visible'       => true,
        'required'      => false,
        'user_defined'  => false,
        'default'       => '',
        'searchable'    => false,
        'filterable'    => false,
        'comparable'    => false,
        'visible_on_front' => false,
        'unique'        => true,
    );
$installer->addAttribute(3, 'custom_field', $attrib);

The field shows up fine in the admin, and when I create the category in my script like so:

$p_category = Mage::getModel('catalog/category')
            ->setStoreId(0)
            ->load(2);
$category = Mage::getModel('catalog/category');
$category->setStoreId(0)
    ->setName('Test Category')
    ->setCustomField('abcd')
    ->setDisplayMode('PRODUCTS')
    ->setAttributeSetId($category->getDefaultAttributeSetId())
    ->setIsActive(1)
    ->setIsAnchor(1)
    ->setPath(implode('/',$p_category->getPathIds()))
    ->setInitialSetupFlag(true)
    ->save();

I can see the value ‘abcd’ in the Magneto admin interface. But when I call the code below:

<?php
$category = Mage::getModel('catalog/category')->loadByAttribute('custom_field', 'abcd');
print_r($category);
?>

I get no result. But if I loadByAttribute using the ‘name’ field set to ‘Test Category’, I DO get a result.

So, in the database, I looked into the catalog_category_entity_varchar table and noticed that the ‘name’ attribute had an entry for both store_id = 0 AND store_id = 1 whereas the ‘custom_field’ attribute had only an entry for store_id = 1.

When I added a store_id = 0 entry for ‘custom_field’ with the value set to ‘abcd’ in the catalog_category_entity_varchar table, loadByAttribute got the expected result.

My question is, why is the ‘name’ field getting a store_id = 0 entry in catalog_category_entity_varchar and my custom field is not?
How do I load categories by custom attributes?

  • 1 1 Answer
  • 2 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-16T15:04:54+00:00Added an answer on May 16, 2026 at 3:04 pm

    I’m running 1.4.1.1 and noticed a similar issue with a custom product attribute. If you filter a collection by an attribute that attribute has to have a value for the default store as well as the store you’re interested in. You can see why if you do the following

    Mage::Log($collection->getSelect()->__toString());
    

    When you look at the query in the log file you’ll see that magneto does an inner join onto the attribute table for store_id 0, so if you haven’t created a value for store zero it can’t give you a result. Seems like a bug to me, I think Magento should do a LEFT JOIN.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a custom post type named People. I have created a page
I have created several custom attributes for my products. I have some that need
I have an array of objects which created from a custom class. The custom
I have created a custom module which displays a tab and a section in
I have a set of links with custom HTML5 data attributes like this one:
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
I have created custom cell in which there are n number of image views.
friends, i have created custom title bar using following titlebar.xml file with code <?xml
I have created a custom cell for loading into a table. The interface is

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.