Last active
August 29, 2015 14:08
-
-
Save splacento-incomm/2818f43195d28b0850b8 to your computer and use it in GitHub Desktop.
Magento useful snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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