0

I create ajaxDeleteProduct function, it's ok, but it not render layout after success, please help me fix it

My function

public function ajaxDeleteAction()
{
    $id = (int) $this->getRequest()->getParam('id');
    $result = array();
    if ($id) {
        try {
            $this->_getCart()->removeItem($id)->save();

            $result['qty'] = $this->_getCart()->getSummaryQty();

            $this->loadLayout();
            $result['content'] = $this->getLayout()->getBlock('minicart_content')->toHtml();
            $result['toplink'] = $this->getLayout()->getBlock('top.links')->toHtml();
            $result['success'] = 1;
            Mage::dispatchEvent('ajax_cart_remove_item_success', array('id' => $id));
        } catch (Exception $e) {
            $result['success'] = 0;
        }
    }

    $this->getResponse()->setHeader('Content-type', 'application/json');
    $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
}

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.