Skip to content

Instantly share code, notes, and snippets.

@splacento-incomm
Last active August 29, 2015 14:08
Show Gist options
  • Save splacento-incomm/2818f43195d28b0850b8 to your computer and use it in GitHub Desktop.
Save splacento-incomm/2818f43195d28b0850b8 to your computer and use it in GitHub Desktop.
Magento useful snippets
$collection = $productModel->getCollection()
->addAttributeToSelect(array('sku', 'price', 'my_attribute')) //load only stuff you need
->addAttributeToFilter('attribute_set_id','16') //from attribute set 16
->joinField('qty',
'cataloginventory/stock_item',
'qty',
'product_id=entity_id',
'{{table}}.stock_id=1',
'left'); //add qty
Mage::getSingleton('cataloginventory/stock')->addInStockFilterToCollection($collection); //add is in stock :) *without QTY!*
$_product->getAttributeText('my_attribute') //depends on attribute type
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment