Sorry for my English.

I have this code.

 $productCollection = Mage::getModel('catalog/product')
        ->addAttributeToFilter('qty', array("gt" => 0))


I need get a product name , and I use this ->addAttributeToSelect('name') on my collection, but My collection don't return the data.

in attribute settings, I have this

enter image description here

How can I get all the product data in general?


Extending beyond my original answer here are some of the things you can do with product collections. Mixture of filters and functionality to fetch more data.

// Load Product Collection
$collection = Mage::getModel('catalog/product')->getCollection();
$collection = Mage::getResourceModel('catalog/product_collection');
// only products which are visible in frontend
// Only Enabled products remain in the collection
// Only products that are in stock
// Add All Product Attributes
// Add Individual Product Attributes
$collection->addAttributeToSelect('name', 'description', 'brand');
// Add Specific Price Attributes
// Add Category IDs to Products
// Add Tier Pricing Info
// Add Product URL Rewrites
// Or (Wrong?)
    array('status', 'status'),
    array(array('neq' => 1), array('null' => true))
// Or
        'attribute' => 'download_link',
        'null'      => true,
        'attribute' => 'download_link',
        'eq'        => '',
// Filter Collection
// Is Equal To
$collection->addAttributeToFilter('status', array('eq' => 1));
// Is Not Equal To
$collection->addAttributeToFilter('visibility', array('neq' => 1));
// Greater Than
$collection->addAttributeToFilter('price', array('gt' => 3));
// Less Than
$collection->addAttributeToFilter('price', array('lt' => 3));
// Greater Than or Equal To
$collection->addAttributeToFilter('price', array('gteq' => 4));
// Less Than or Equal To
$collection->addAttributeToFilter('price', array('lteq' => 4));
// Contains – with % wildcards
$collection->addAttributeToFilter('sku', array('like' => 'DVD%'));
// Does Not Contain – with % wildcards
$collection->addAttributeToFilter('sku', array('nlike' => 'ABC%'));
// In Array
$collection->addAttributeToFilter('entity_id', array('in' => array(1,3,12)));
// Not In Array
$collection->addAttributeToFilter('entity_id', array('nin' => array(1,2,12)));
// Is NULL
$collection->addAttributeToFilter('description', 'null');
$collection->addAttributeToFilter('description', array('null' => true));
// Is Not NULL
$collection->addAttributeToFilter('description', 'notnull');
$collection->addAttributeToFilter('description', array('notnull' => true));
// Further Filtering
// Filter by Product IDs
// Filter by Current Store
// Filter by Current Website
// Filter by Category
// Sort Collection
// er by Attribute Ascending
$collection->setOrder('price', 'ASC');
// er by Attribute Descending
$collection->setOrder('name', 'DESC');
// Random Order
// Limit Collection
// Count Results
// Return Only Product IDs
// Debug Collection
// Static type strings

Try this

$productCollection = Mage::getModel('catalog/product')
        ->addAttributeToFilter('qty', array("gt" => 0))
  • it doesn't work either. ->addAttributeToSelect does not work at all – Denis Maksiura Jun 15 at 10:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.