organicinternet/magento-configurable-simple — Issue #58: Page Not Found - invalid ajaxBaseUrl
Author: cschuler
Created: 2011-10-10 20:02:59+00:00
State: open

After you select all of your options, SCP will make an AJAX request to get tiered pricing info.

I was having an problem where instead of a pricing table, the script was pulling in an entire "404 Page not Found" page and inserting it into the SCPcustomOptionsDiv.

After a little digging around, I found that the problem was that the config variable 'ajaxBaseUrl' on my site was getting set to:

```
http://my.domain.com/oi/ajax/?___SID=U
```

The problem is that the ajax request tries to append a path & additional parameters to that URL. And since the ajaxBaseUrl already has parameters, this ends up creating a garbled URL:

```
http://my.domain.com/oi/ajax/?___SID=Uco/?id=4&pid=1
```

To correct the issue, I replaced the following line in scp_product_extension.js (in Product.Config.prototype.showCustomOptionsBlock, line 271 )

Old Code:

```PHP
var coUrl = this.config.ajaxBaseUrl + "co/?id=" + productId + '&pid=' + parentId;
```

New Code:

```PHP
var coUrl;
if ( this.config.ajaxBaseUrl.indexOf('?') > 0 ) {
var coURLtmp = this.config.ajaxBaseUrl.split('?',2);
coUrl = coURLtmp[0] + "co/?id=" + productId + '&pid=' + parentId + '&' + coURLtmp[1];
}else{
coUrl = this.config.ajaxBaseUrl + "co/?id=" + productId + '&pid=' + parentId;
}
```

After the change, the URL which is requested is formatted correctly, and I no longer get a 404 page:

```
http://my.domain.com/oi/ajax/co/?id=4&pid=1&___SID=U
```

Has anybody else had this problem?

Magento ver. 1.6.1.0-rc1