Full Page Cache invalidation on cart (quote) change

前端 未结 2 1097
孤城傲影
孤城傲影 2021-02-04 20:38

I\'m trying to add a block (button) to mini cart block: either to name=\"cart_sidebar\" or preferably name=\"topCart.extra_actions\" as it renders it\'

2条回答
  •  执念已碎
    2021-02-04 21:29

    To anyone looking for a solution to the extra_actions PayPal button, there is a Magento patch fixing it (SUPEE-87_1.12.0.0_v1.patch).

    Since it's a Magento patch, you can simply open the file "app/code/core/Enterprise/PageCache/Model/Container/Sidebar/Cart.php" and add these 2 functions after the _renderBlock function, which is exactly what the patch does:

        /**
     * Get Place Holder Block
     *
     * @return Mage_Core_Block_Abstract
     */
    protected function _getPlaceHolderBlock()
    {
        $block = parent::_getPlaceHolderBlock();
        $block->setChild('extra_actions', $this->_getExtraActionsChildBlock());
        return $block;
    }
    
    /**
     * Get child Block
     *
     * @return Mage_Core_Block_Abstract
     */
    protected function _getExtraActionsChildBlock()
    {
         $paypalShortcutBlock = Mage::app()->getLayout()->createBlock('paypal/express_shortcut');
         $paypalShortcutBlock->setTemplate('paypal/express/shortcut.phtml');
         $paypalShortcutBlock->setLayout(Mage::app()->getLayout());
    
         return $paypalShortcutBlock;
    }
    

    Understanding how this works can help for other similar problems.

    Thanks Vinai by the way, very informative answer.

提交回复
热议问题