Kriuchko
1/9/2019 - 10:44 AM

Products count loaded product collection loaded products collection

Magento 1 loaded product collection

<?php 
    $_productCollection = $this->getLayout()->getBlockSingleton('catalog/product_list')->getLoadedProductCollection();
    if( $count = $_productCollection->getSize() )
    {
       echo $count; 
    }
?> 

---------------------------------

<?php $attributes = Mage::getResourceModel('eav/entity_attribute_collection')
            ->setEntityTypeFilter($product->getResource()->getTypeId())
            ->addFieldToFilter('attribute_code', 'city ') 
            ->load(false);     
        $attribute = $attributes->getFirstItem()->setEntity($product->getResource());                 
        $city = $attribute->getSource()->getAllOptions(false);                            
?>
<div class="city-choose">
   <form action="#">
     <fieldset>
       <strong class="title"><img src="<?php echo $this->getSkinUrl();?>/images/text-more-off.png" alt="more off getting off in" /></strong>
       <div class="form">
         <label for="city">Choose another city</label>
         <select class="city-select" id="city" ONCHANGE="location = this.options[this.selectedIndex].value;" >
           <?php foreach ($city as $_category):?>
           
               <option <?php if ($_GET['city'] == $_category['value']):?>selected<?php endif;?>
               VALUE="<?php print Mage::getUrl('*/*/*', array (
                                                   '_current' => 1,
                                                   '_escape' => 1,
                                                   '_use_rewrite' => 1,
                                                   '_query' => array
                                                       (
                                                           'city' => $_category['value']
                                                       )
                                               ));?>
               "><?php print $_category['label'];?></option>
           
           <?php endforeach;?>
         </select>
       </div>
     </fieldset>
   </form>
 </div>