1

I am trying to split product listing page in two part.

I have one attribute without_offer. By default all product have some offers. If any product does not have any offer it should be came in WITHOUT OFFER list.

Let say on product listing page there are 100 product and setting is selected 50 products per page. Out of first 50 products 25 with some offers and 25 without offers.

So product listing on category page like,

WITH OFFER

  • Product1
  • Product2
  • ... to Product25

WITHOUT OFFER

  • Product1
  • Product2
  • ... to Product25

By default products sorting by name.

Is there any way i can split product collection in two part?

1
  • Anything new here?
    – sv3n
    Commented Oct 13, 2017 at 8:49

3 Answers 3

0

Change the attribute property Used for Sorting in Product Listing to Yest and from the System -> Configuration -> Catalog -> Frontend Select without_offer attribute and save configuration and after cache refresh check frontend..

2
  • But we need default sorting by name Commented Jul 1, 2017 at 9:01
  • then try to add some filter in "$_productCollection=$this->getLoadedProductCollection();" Commented Jul 1, 2017 at 9:10
0

You can "filter" a collection with using $collection->getItemsByColumnValue()

In case withoutOffer is a yes/no attribute, this should work (example for specific category):

# $category = Mage::registry('current_category');
$category = Mage::getModel('catalog/category')->load(41);
$collection = $category->getProductCollection();
$collection->addAttributeToSelect(array('name', 'without_offer'));
$collection->setOrder('name', Zend_Db_Select::SQL_ASC);
$withoutOffer = $collection->getItemsByColumnValue('without_offer', 1);

foreach ($withoutOffer as $item) {
    var_dump($item->getData());
}
0

@sv3n 's answer is bang on. I might add, i managed the same here with an array of dropdown options by doing something like this..

<?php
      $groupattr = Mage::getModel('eav/config')->getAttribute('catalog_product', 'display_group');

      $allOptions = $groupattr->getSource()->getAllOptions(true, true);
      foreach ($allOptions as $instance=>$arr) {
        $id = $instance['value']; //id of the option
        $value = $instance['label']; //Label of the option

        if(in_array('Left',$arr))
         {
           $leftkey = $arr['value'];//['label']
         }
        if(in_array('Right',$arr))
         {
           $rightkey = $arr['value'];//['label']
         }
      }
    ?>
    <?php
    $left = $_productCollection->getItemsByColumnValue('display_group', $leftkey);
    $right = $_productCollection->getItemsByColumnValue('display_group', $rightkey);;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.