0

In a previous question, I was trying to create a block which would show all products for that category - which now works. Yippee!

However, the problem now is - while I was able to create a 'simple list' by removing the formatting from the standard list.phtml, I still get the pagination etc with the tool bar.

If I hide or remove the toolbar, this still only shows the first 10 (or whatever is set in config) products. I don't want to change this globally, only in the block.

So the question is, how can I adjust my new simple-list.phtml to show all products by default?

(code is below)

<?php
/**
 * Show all products in a simple list - template
 */
?>

<?php
    $_productCollection=$this->getLoadedProductCollection();
    $_collectionSize = $_productCollection->count();
?>

<?php if ($_collectionSize && $tmpHtml = $this->getChildHtml('block_category_above_collection')): ?>
    <div class="block_category_above_collection std"><?php echo $tmpHtml; ?></div>
<?php endif; ?>

<?php if(!$_collectionSize): ?>
    <?php if ($tmpHtml = $this->getChildHtml('block_category_above_empty_collection')): ?>
        <div class="block_category_above_empty_collection std"><?php echo $tmpHtml; ?></div>
    <?php else: ?>
        <p class="note-msg empty-catalog"><?php echo $this->__('There are no products matching the selection.') ?></p>
    <?php endif; ?>
<?php else: ?>

<?php
    $_helper = $this->helper('catalog/output');
    $theme = $this->helper('ultimo');
    $helpLabels = $this->helper('ultimo/labels');
    $helpTemplate = $this->helper('ultimo/template');
    $helpImg = $this->helper('infortis/image');

    //Hide the toolbar?
    $hideToolbar = false;
    if ($this->getHideToolbar())
    {
        $hideToolbar = true;
    }
?>

<div class="category-products">
    <?php if (!$hideToolbar): ?>
        <?php echo $this->getToolbarHtml() ?>
    <?php endif; ?>
    <?php if($this->getMode()!='grid'): //List mode ?>

    <?php $_iterator = 0; ?>
    <ul class="products-list<?php if($listClasses) echo $listClasses; ?>" id="products-list">
    <?php foreach ($_productCollection as $_product): ?>
        <li class="item<?php if( ++$_iterator == sizeof($_productCollection) ): ?> last<?php endif; ?>">
            <?php //Product description ?>
            <div>
                <div>
                    <?php $_productNameStripped = $this->stripTags($_product->getName(), null, true); ?>
                    <p><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped; ?>"><?php echo $_helper->productAttribute($_product, $_product->getName() , 'name'); ?></a></p>

                </div>
            </div> 
        </li>
    <?php endforeach; ?>
    </ul>  

    <?php else: //Grid mode ?>
        <!-- deleted grid mode section  -->
    <?php endif; //end: if grid mode ?>

    <?php if (!$hideToolbar): ?>
        <div class="toolbar-bottom">
            <?php echo $this->getToolbarHtml() ?>
        </div>
    <?php endif; ?>
</div>
<?php endif; ?>

<?php if ($_collectionSize && $tmpHtml = $this->getChildHtml('block_category_below_collection')): ?>
    <div class="block_category_below_collection std"><?php echo $tmpHtml; ?></div>
<?php endif; ?>
0

Same problem was pointed here and Marius solved it. I recommend you to read the full thread since there are a few answers with info.

  • thanks. I also found this site: krcodex.blogspot.de/2013/05/…, and by using the code there - I got it working very easily. Thanks! – egg Jun 11 '14 at 11:40
  • Your link is dead, you should have included the infos in your post. – Black Mar 21 at 15:04
0

Update: using this link, I leveraged the code to create the solution below that works nicely.

<?php
/**
 * Show all products in a simple list - template
 */
?>

<?php
    $_productCollection=$this->getLoadedProductCollection();
    $_collectionSize = $_productCollection->count();
?>

<?php if ($_collectionSize && $tmpHtml = $this->getChildHtml('block_category_above_collection')): ?>
    <div class="block_category_above_collection std"><?php echo $tmpHtml; ?></div>
<?php endif; ?>

<?php if(!$_collectionSize): ?>
    <?php if ($tmpHtml = $this->getChildHtml('block_category_above_empty_collection')): ?>
        <div class="block_category_above_empty_collection std"><?php echo $tmpHtml; ?></div>
    <?php else: ?>
        <p class="note-msg empty-catalog"><?php echo $this->__('There are no products matching the selection.') ?></p>
    <?php endif; ?>
<?php else: ?>

<?php
    $_helper = $this->helper('catalog/output');
    $theme = $this->helper('ultimo');
    $helpLabels = $this->helper('ultimo/labels');
    $helpTemplate = $this->helper('ultimo/template');
    $helpImg = $this->helper('infortis/image');

?>

 <!-- just hacking a test  -->
<?php
       $product_collection = Mage::getModel('catalog/product')->getCollection()->setOrder('name', 'asc'); 

       //getting the product collection, results are ordered by product name

      foreach($product_collection as $_product)
       {
           ?><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped; ?>"><?php echo $_helper->productAttribute($_product, $_product->getName() , 'name'); ?> - </a><?php
           echo "Product ID: ";
           echo $_product->getId() . " - ";
           echo "SKU: ";
           echo $_helper->productAttribute($_product, $_product->getSKU() , 'sku'). "<br />";
       }
?>

<?php endif; ?>

<?php if ($_collectionSize && $tmpHtml = $this->getChildHtml('block_category_below_collection')): ?>
    <div class="block_category_below_collection std"><?php echo $tmpHtml; ?></div>
<?php endif; ?>
  • OK, nightmare... this works on my localhost.. but on my live server, it shows the Product ID, but for the other variables - nothing. What could be the cause of that? – egg Jun 11 '14 at 12:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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