I want to override wishlist block in my custom theme. Whenever Customer increases the QTY on wishlist page for add to cart, I want to place the condition that QTY should be less than 5.

This function is already written in /Mage/Wishlist/Block/Customer/Wishlist/Item/Column/Cart.php.

I want to override this in my custom theme.


class Gt_Wishlist_Block_Customer_Wishlist_Item_Column_Cart extends 

     * Returns qty to show visually to user
     * @param Mage_Wishlist_Model_Item $item
     * @return float
    public function getAddToCartQty(Mage_Wishlist_Model_Item $item)
        $qty = $item->getQty();
        return $qty ? $qty : 1;

     * Retrieve column related javascript code
     * @return string
    public function getJs()
        $js = "
            function addWItemToCart(itemId) {
                var url = '" . $this->getItemAddToCartUrl('%item%') . "';
                url = url.gsub('%item%', itemId);
                var form = $('wishlist-view-form');
                if (form) {
                    var input = form['qty[' + itemId + ']'];
                    if (input) {
                        var separator = (url.indexOf('?') >= 0) ? '&' : '?';
                        url += separator + input.name + '=' + encodeURIComponent(input.value);
                        if(input.value > 5){
                            alert('Select between 1 to 5');
                            return false;

        $js .= parent::getJs();
        return $js;


<?xml version=""?>

These two files i have overriden in my custom theme as i shared folder path. Please help me.

1 Answer 1


You have to rewrite Mage/Wishlist/Block/Customer/Wishlist/Item/Column/Cart.php in local codepool instead of theme.

app/code/... will be rewrited in local codePool.

app/design/... will be overrited in current theme.

Now according to this rules, your block will be rewrited of course in local.

You have good This Inchoo explanation for rewriting blocks, helpers, controllers, etc...

  • I have read that blog, but I am not getting properly. I i want to only override that cart.php, is it compulsory to override other folders such etc, controllers, models, sql ?? Please help me.
    – gt06
    Oct 16, 2017 at 13:42
  • No, you have just rewrite this block, and not necessarily the others controllers, models ...
    – PЯINCƎ
    Oct 16, 2017 at 13:47
  • so what will be the next step to override this cart.php. I have done this 3 times. but not overriding that block.
    – gt06
    Oct 17, 2017 at 4:01

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.