0m3r
2/3/2014 - 8:52 AM

ajaxpro Highlight 'bug' was fixed (function getAddToCartUrl was added/overrided)

ajaxpro Highlight 'bug' was fixed (function getAddToCartUrl was added/overrided)

// line 380

/**
     * Retrieve url for add product to cart
     * Will return product view page URL if product has required options
     *
     * @param Mage_Catalog_Model_Product $product
     * @param array $additional
     * @return string
     */
    public function getAddToCartUrl($product, $additional = array())
    {
        if (!class_exists('TM_AjaxPro_Block_Product_List')) {
            return parent::getAddToCartUrl($product, $additional);
        }

        if (!Mage::getStoreConfig('ajax_pro/general/enabled')
            || !Mage::getStoreConfig('ajax_pro/catalogProductView/enabled')
            || TM_AjaxPro_Model_UserAgent::isSearchBot()
            || (TM_AjaxPro_Model_UserAgent::isMobile()
                    && Mage::getStoreConfig('ajax_pro/general/disabledOnMobileDevice'))
            ) {
            return parent::getAddToCartUrl($product, $additional);
        }
        if (defined('Mage_Core_Model_Url::FORM_KEY')) {
            $formKey = Mage::getSingleton('core/session')->getFormKey();
            if (!empty($formKey)) {
                $additional = array_merge(
                    $additional,
                    array(Mage_Core_Model_Url::FORM_KEY => $formKey)
                );
            }
        }

        if ($product->getTypeInstance(true)->hasOptions($product)
            || 'grouped' === $product->getTypeId()) {

            if (!isset($additional['_escape'])) {
                $additional['_escape'] = true;
            }
            if (!isset($additional['_query'])) {
                $additional['_query'] = array();
            }
            $additional['_query']['options'] = 'cart';

            $_url = $product->getUrl();
            $product->setUrl(null);
            $url =  parent::getProductUrl($product, $additional);
            //$url = $this->getProductUrl($product, $additional);
            $product->setUrl($_url);
            return $url;
        }

        return parent::getAddToCartUrl($product, $additional);
    }