1

I am trying to set child to another block using the following script :

public function refreshlistAction() {
    $data = $this->getRequest()->getParams();
    if (isset($data['delivery'])) {
        $layout = $this->getLayout();
        $blockPager = $layout->createBlock('page/html_pager','product_list_toolbar_pager');
        $blockToolbar = $layout->createBlock('catalog/product_list_toolbar', 'product_list_toolbar')->setTemplate('catalog/product/list/toolbar.phtml');
        $blockToolbar->setChild('product_list_toolbar_pager',$blockPager);
        $block = $layout->createBlock('catalog/product_list', 'product_box_list')->setTemplate('catalog/product/list.phtml');
        $block->setChild('toolbar', $blockToolbar);
        $block->setCategoryId($data['category']);
        $session = Mage::getSingleton('core/session');
        //let's check if there is not a delivery mode set and a product in the cart
        if (($session->hasDelivery())&&(!empty($session->getDelivery()))&&(!empty(Mage::getModel('checkout/cart')->getProductIds()))&&($session->getDelivery()!=$data['delivery'])){
            Mage::getSingleton('core/session')->addNotice($this->__("Your cart is not empty. Therefore, you cannot adopt a different delivery mode"));
            $data['delivery'] = $session->getDelivery();
        }
        $block->setFilterDelivery($data['delivery']);
        $session->setDelivery($data['delivery']);
        $html = $block->toHtml();
        $this->getResponse()
                ->setHeader('Content-Type', 'text/html')
                ->setBody($html);
        return;
    } else {
        echo $this->__('This page cannot be accessed');
    }
}

The product list and toolbar are returned and can be displayed but the pager is not. If I make a var_dump in toolbar.php(line 809) :

$pagerBlock = $this->getChild('product_list_toolbar_pager');
var_dump($pagerBlock);

$pagerBlock contains a boolean (false).

Is there something I am missing ?

My idea is to refresh the product list with ajax on an attribute filtering.

1 Answer 1

0

I was going little bit the wrong way. I overrode the catalog/product_list to fit to this answer https://magento.stackexchange.com/a/16958/9489, I did not need to reload toolbars or so on and it works like a charm.

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.