if you want to get only one column from product collection. you can write look like.
$product_collection = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('*');
var_dump($product_collection->getFirstItem()->getData());
echo $product_collection->getFirstItem()->getName();
echo $product_collection->getLastItem()->getName();
var_dump($product_collection->getLastItem()->getData());
$product_collection = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('*');
var_dump($product_collection->getColumnValues('name'));
get product with name anant
var_dump($product_collection->getItemsByColumnValue('name','anant'));
get first or last item/row from the collection
var_dump($product_collection->getFirstItem()->getData());
echo $product_collection->getFirstItem()->getName();
echo $product_collection->getLastItem()->getName();
var_dump($product_collection->getLastItem()->getData());
get Collection data as XML or convert collection in xml
var_dump($product_collection->getFirstItem()->toXml() );
No comments :
Post a Comment