Magento Forum

   
Multistore: Can’t add to cart from product view - wrong URL in productAddToCartForm.sumbit
 
thisisklara
Jr. Member
 
Total Posts:  4
Joined:  2012-11-13
 

Hi everyone.
I have a problem with add to cart on product pages in a Magento Multistore and it’s driving me insane. Whenever I try to add a product to the cart from the second website (which houses the second store), I get “article could not be added to the cart”. This is because the action on the button – getSubmitUrl – transmits the wrong product URL.
Please please help.

Here’s the situation in detail:
I have a installed a new Magento 1.7 Community Edition that is supposed to run both a b2c store and a b2b store. For this, I made two websites in the system configuration, each with two stores and each store with two store views for German and English.
Both b2b and b2c share the same catalogue, but prices, taxes, customer registration and a bunch of other things will be different. However, none of these things are implemented yet and the installation is completely new.

The main magento installation is here:
http://www.mystim.com/store/
It points to the b2c website. Everything works perfectly here.

For the b2b website, I created the subfolder
http://www.mystim.com/store/b2b/
It contains the adapted index.php and the ht.access

The website configuration of the b2b website is the same for secure and unsecured:
Base URL - http://www.mystim.com/store/
Base Link URL - http://www.mystim.com/store/b2b/
Everything else is set to default.

This is what happens
If you want to add a simple product to the cart in the b2b store, it works from the list view but not from the product view. For the product view, I get “article can’t be added to cart”.
In the list view, the “add to cart” button calls the function

onclick=\\\"setLocation(\\\'<?php echo $this->getAddToCartUrl($_product) ?>\\\')\\\"
which works fine.
In the product view, the button calls
productAddToCartForm.submit(this)
which transmits the wrong URL: It should return http://www.mystim.com/store/produkt.html, but it returns http://www.mystim.com/store/b2b/produkt.html - it includes the subfolder.
The form in productAddToCartForm calls the action
$this->getSubmitUrl($_product)

That seems to reference the Base Link URL that I put in the settings, not the Base URL. But if I change the Base Link URL in the configuration, the b2b store can’t be called at all and immediately switches to the b2c version.
Sort of defeating the whole purpose of the whole thing.
Now I found the problematic function productAddToCartForm in the Abstract.php and it says:
/**

    public function getAddToCartUrl($product, $additional = array())
    {
        if ($product->getTypeInstance(true)->hasRequiredOptions($product)) {
            if (!isset($additional[\\\'_escape\\\'])) {
                $additional[\\\'_escape\\\'] = true;
            }
            if (!isset($additional[\\\'_query\\\'])) {
                $additional[\\\'_query\\\'] = array();
            }
            $additional[\\\'_query\\\'][\\\'options\\\'] = \\\'cart\\\';

            return $this->getProductUrl($product, $additional);
        }
        return $this->helper(\\\'checkout/cart\\\')->getAddUrl($product, $additional);
    }

public function getSubmitUrl($product, $additional = array())
    {
        $submitRouteData = $this->getData(\\\'submit_route_data\\\');
        if ($submitRouteData) {
            $route = $submitRouteData[\\\'route\\\'];
            $params = isset($submitRouteData[\\\'params\\\']) ? $submitRouteData[\\\'params\\\'] : array();
            $submitUrl = $this->getUrl($route, array_merge($params, $additional));
        } else {
            $submitUrl = $this->getAddToCartUrl($product, $additional);
        }
        return $submitUrl;
    }

So I’m guessing that SubmitRouteData is the problem, but I just don’t see how to fix it.

Interestingly, adding product to the wishlist from the product view works perfectly. That calls the function productAddToCartForm.submitLight.

So what the heck am I doing wrong?

These are the things I already tried without success after hours and hours of googling:
Adding the directory „var/tmp“ to the subfolder that holds the index.php of the b2b website
Switching to all possible combinations of Base URL and Base Link URL (always the same error message)
Making the index.php run a website instead of a store

I don’t care about pretty anymore. Doesn’t have to be elegant. It just hast o freaking work. Somehow.
Pleeeasssesomeone have mercy and help.
Klara

File Attachments
index.php  (File Size: 3KB - Downloads: 20)
 
Magento Community Magento Community
Magento Community
Magento Community
 
NUsportvoeding
Jr. Member
 
Total Posts:  3
Joined:  2012-11-07
 

I have got a similiar problem, It looks pretty much like this problem. I have posted a topic here:

http://www.magentocommerce.com/boards/viewthread/421358/

When i figured something out I will reply here aswell....

Greetings

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top