I try to list all product names in a store, so I try the following code.
$collection = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*')->setPageSize(5000)->setCurPage(1);
$collection->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED);
foreach ($collection as $product) {
echo $product->getName();
echo "<br>";
}
This gives the following result.
After that I try to sort this. The code is:
$collection = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*')->setPageSize(5000)->setCurPage(1);
$collection->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED);
foreach ($collection as $product) {
$pro[] = $product->getName();
}
sort($pro);
foreach ($pro as $pr) {
echo $pr; echo"<br>";
}
This gives the following result.
It gives two lists in ascending order.
Why does it behave like this?
I need only one list with ascending order for that. What should I do?