I am adding a widget to a CMS page. Within this widget will be some ajax calls -- however, i'm unsure what / how I should call this layout block in the controller to update the frontend code.

The widget is located here:


In the CMS page I can calling the widget as such:

{widget type="catalog/product_widget_new" display_type="new_products" show_pager="1" products_per_page="20" products_count="1000" template="catalog/product/widget/new/content/new_grid.phtml"}

The ajax calling function will look something like:

newPerPage = function (value) {
    try {
            url: url,
            dataType: 'json',
            type: 'post',
            data: value,
            success: function (data) {
    } catch (e) {

The ajax conotroller function will look something like:

public function newPagerAction(){
    $this->setData('products_per_page', param);
    $response = array();
    $response['field'] = $this->getLayout()->createBlock('....')->setTemplate('....')->toHtml();

1 Answer 1


Try this in your controller:

public function couponPostAction()
    if (!$this->getRequest()->isAjax()) {

    $block = $this->getLayout()->createBlock('catalog/product_widget_new', 'product.widget.new', array(
        'show_pager'        => 1,
        'products_per_page' => 24,
        'products_count'    => 1000,
        'display_type'      => 'new_products',
        'template'          => 'catalog/product/widget/new/content/new_grid.phtml'

            'field' => $block->toHtml()
  • I assume you mean instead of '24' I will use the data passed to the controller, right? Thank you regardless. This is essentially exactly what I needed. Jan 22, 2015 at 18:12
  • Yes, you can pass data in ajax call and fetch it with $this->getRequest()->getParam('someparam'); Jan 22, 2015 at 18:14
  • Any idea of an appropriate place to put this controller? Or should I just make a new module? Jan 22, 2015 at 18:24
  • You should place it in the controllers folder inside either new or existing custom module and adjust url var in your javascript accordingly. Jan 22, 2015 at 18:31

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.