2

I am making a small module to display a product list with content depending on the URI.

/storeid/parts/ would be the base, with all parts/products

/storeid/parts/mobile would contain all parts in category mobile -> parts etc..

I got to the point where it's rendering the page layout with my custom search block, but now ,how do I append a product list after the search bar?

Current code:

    $this->loadLayout();
    $items = [];
    $model = Mage::getModel('catalog/category');
    $url = rtrim(Mage::helper('core/url')->getCurrentUrl(), '/');
    foreach(explode(',', $brands) as $item) {
        $name = $model->load($item)->getName();
        $items[] = [
            'url' => $url . "/" . $this->sanitize($name),
            'name' => $name
        ];
    }

    $block = $this->getLayout()->createBlock('core/template');
    $block->setTemplate('mavalier/parts/filter.phtml')->assign([
        'params' => $params,
        'items' => $items
    ]);
    $this->getLayout()->getBlock('content')->append($block);

    $block2 = $this->getLayout()->createBlock('core/template')->setTemplate('catalog/product/list.phtml');
    $this->getLayout()->getBlock('content')->append($block2);

    $this->renderLayout();

I feel like this is close, but it says Fatal error: Call to a member function count() on null in C:\Users\natha\Documents\CM24\app\design\frontend\parasol\default\template\catalog\product\list.phtml on line 51 which makes me think $this->getLoadedProductcollection() returns null..

How do I 'set' the LoadedProductCollection?

To be honest, if you think the code i've got is wrong or isn't how Magento is intended;

I get that, but this is more a proof of concept rather than production material anyway.

Your Answer

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

Browse other questions tagged or ask your own question.