Magento ignores extra URL parameters set - magento

I am trying to open a Magento store link from an external site. While opening the store link I need to send some information using the query string parameters.
So I open a link (through php code) such as:
http://magentostore.com/myproduct.html?id=3434&user=445
However the Magento store link ignores the query string parameters and reloads the page as:
magentostore.com/myproduct.html
I checked in Firebug and can see that there was a redirect to the Magento store without the query string parameters. Is there a way to override this behavior and let Magento load with the query string parameters?
What setting can I do in the Magento store to let it allow using the query string parameters?
Is there any other way of sending some more information to the Magento store page?
Is there a way to find out if its Magento doing this and not the server?
Thanks

Magento is receiving the queries on the first request but redirects to the URL it has in the URL Rewrite list. This is probably for SEO reasons. Whatever code you have that needs those values should store them in a session variable before the redirect happens.
deveffort says:
I researched for the URL rewrites and looks like there was a URL redirect for the product link! I have removed it and have my scenario working. However would be great to know if there is anything that can be done to make sure the Magento code does not do any query string parameter sanitization. Thanks a lot..
clockworkgeek says:
I fear removing that rewrite is temporary. It will replace itself on the next product re-index or perhaps when the product is saved. Since you only want to set some cookies it needn't be done by javascript, that is less reliable anyway.
Instead, create an observer to watch for an event of catalog_controller_product_view. Have the observer check for the query parameters, and if the correct one exists, set the cookie. Also it might try checking the referrer URL matches what you expect of it, that might make spoofing the values a little harder.

Related

Is there any way to replace "&" with "&" in Magento URL

Is there any way to to replace & with & in magento url.
Every time when magento URL is redirecting from one store to another it is adding & between the url. And the url is breaking. for eg:
https://www.indelust.com/designer?d=370
Above URL is the default url which is linked to US storeview based on US geoIP. When I am clicking on the url from Google search results it should redirect me to the same page with respective storeview. Now below url is the one when I clicked on google search result.
https://indelust.com/in/designer?___store=in_storeview&d=370
And the above link is breaking.
When I am making a small correction in the above url, by changing & to &. Then it is working fine for me.
I gone through some tutorials and below I found the relevant one, but I did not get the answer to resolve based on magento url pattern.
https://magento.stackexchange.com/questions/38513/amp-instead-of-in-language-switch-url
Can anybody help me?
You should find out why the issue appears, but if you just want to replace the url you should add this to your .htaccess file:
RewriteEngine On
RewriteRule ^(.*)&(.*)$ /$1&$2 [L,R=301]
An htaccess file is a set of rules a server runs through for each page request. Adding all of your old URLs to this file means that for every page visit your server has to do a lot more work - it has to compare the URL the user is visiting to all of the old URLs you have added to the file. Magento isn't renowned for its blistering speed, so slowing down every request seems like something worth avoiding
execute the following query in mysql (via phpmyadmin or command line) to see what the current values are:
select * from core_config_data where path like '%base%url%';
and then update accordingly
update core_config_data set value = 'http://myhostname/js/' where path = 'web/unsecure/base_js_url';

Codeigniter - Htaccess : How to change a controller name

This is my first question here, so Hi all! ^^
I created a website with codeigniter framework and I have inserted a module for multilanguage. The url looks like this:
http://www.mywebsite.com/en/controller/function
The problem came when the client wanted to send a newsletter to all its customers in another language, but do not want to send the url with the controler with the name in english, because the newsletter is for spanish users.So:
URL is going to be send:
http://www.mywebsite.com/es/thecontroller
URL the client wants to be send ("elcontrolador" is "thecontroler" in spanish):
http://www.mywebsite.com/es/elcontrolador
I dont want to create another controler named "elcontorlador" only to show the same page as "thecontroler", because we don't want duplicate content for SEO purposes.
So, i want via .htaccess, a rule that when i type
http://www.mywebsite.com/es/elcontrolador
in the URL, mywebpage shows the info of
http://www.mywebsite.com/es/thecontroler
but with the URL
http://www.mywebsite.com/es/elcontrolador
(the controler "elcontrolador" doesnt exist).
So, is there any way to do this with the htaccess? I've tried it myself but I failed miserably i come here desperate, because I run out of time to deliver it and can not find a viable solution. I'll have to create the extra controller?
Need help D:
Maybe you can use the route config file instead to achieve this ?
$route['es/elcontrolador'] = 'es/thecontroler';
I don't know how you handle your multilangage, but you've got the idea.

Use Magento rest API with multi store view

I have a Magento website with 3 languages on 3 different store view. I need to retrieve product information through the rest API, accessing to this address:
http://-mysite-/api/rest/products
It works really fine, but I receive data only from the default store view. In my webapp I need to switch languages, and I need to access to the others store view. I read the documentation (http://www.magentocommerce.com/api/rest/introduction.html), but I cannot find anything about store view and multilingual sites... I tried passing language in the header or passing the store_id as "get variable"... nothing, it works only with the default store view. Any idea?
You can try this. magentomysite/api/rest/products/store/storeid . For example you can use as magentomysite/api/rest/products/store/1 for english store products.
Remember one thing. In the admin panel you have to give permissions to guest user also. Then only you can get the data through this url.
I hope this helps u.
To elaborate on Pavan's answer the following URL worked for me:
magentodomain.com/api/rest/products/:product_id/store/:store_id
You can find your store id with the following method explained in this answer:
How to find out what my store ID is?

Magento: ?___SID=U appearing in some urls

Can someone please explain why ?___SID=U is appearing in some Magento URLs on my site and not others?
I think it has something to do with sessions but I am not entirely clear. Also, what makes it more confusing is the fact that it's only appearing in some URLs and not others.
I don't need to know how to remove it as I am aware of the setting in the admin area. I would really like an explanation of what it is, what its purpose is and why it would show on some pages and not others. id rather understand what's going on fully than blindly follow some advice as to how to remove it.
I addition to Brendan's answer, the ___SID=U is used in the cache as a placeholder for the session ID. It is replaced by Mage_Core_Model_Url::sessionUrlVar() which in turn calls Mage_Core_Model_Url::sessionVarCallback(). These methods are called from Mage_Core_Block_Abstract::_afterCacheUrl(), which means that any URL found in block output will contain the correct session ID (if needed).
So to get rid of the parameter in your own code the "right way" use this:
$url = Mage::getUrl('some/magento/route'); // might append ___SID parameter
$url = Mage::getModel('core/url')->sessionUrlVar($url); // process ___SID
If the string still displays in the rendered page that is a bug. Are you using some custom caching module, or generating URL's using a non-standard way?
The SID is a "session ID". Magento uses this to track a user's activity within the same Magento installation. Normally, Magento powers one website and one store from one installation (database).
Magento could power multiple websites with multiple stores from one installation though. The SID allows users to stay logged in while navigating across these websites/stores.
I think if you have the function enabled, the SID is sent when accessing catalog URLs so Magento can update the session with the user's location/state for the current website/store.
If you're not running a multi-website or multi-store environment, it's safe to disable the SID on the frontend.
Just something i come across today and though i make a comment, maybe it will help someone.
I found that Magento will format/create an incorrect product url (inc. Session Id) if there were some errors during processing the page. This is not consistent though.
It worth having a look at your server logs for PHP errors.
This is a general Magento 2 bug which is already reported to magento.
Temporary fix is
Go to Document Root,
Find .htaccess and add
RewriteCond %{HTTP_HOST} ^abc.com
RewriteRule ^(.*) www.abc.com/$1 [L,R=301]
below.
This should solve the issue. For me this work in M2.1
All the best.
Reference : https://github.com/magento/magento2/issues/5517
I hunted for hours to find this and the precise answer was a combination of the other answers listed here. First, I cranked up my PHP error reporting and error logging (thanks Gergely Varga). I saw this:
PHP Fatal error: Call to undefined function mb_strrpos() in /var/www/html/app/code/local/ManaPro/FilterAjax/Model/Observer.php on line 59
So, one of our installed extensions requires the php-mbstring package, which my server didn't have installed. As soon as I installed that, the SID=U URLs all disappeared. (In future I'll be running Magento's pre-install checks before copying an existing install over to a new server!)
Thanks to Vinai too for the background of what this tag is for.
Go to Store > Configuration > General > Web > Session Validation Settings > Use SID on Storefrontand and set the value to No.
Clear the Magento cache

Magento multi-domain checkout issues

I have a Magento install with multiple domains (domain1.com, domain2.com) sharing a single checkout URL (checkoutdomain.com). The problem is when I proceed to cart and do to the new domain I get "no items in shopping cart" error. For some reason the session/cookies aren't being passed to the checkout domain.
I'm running Magento 1.7. I've gone to system/config/web/session cookie management and tried all of the following values in the cookie domain field:
.domain.com
.domain.com/
http://www.domain.com
http://www.domain.com
Should something else go here?
I also have cookie path field blank (default) and use http only set to yes (default).
I'm not sure what else to do here.
The first place I'd check is your store setup. Remember that you can't easily share a cart across multiple Websites, only Stores and Store Views (to use Magento's nomenclature).
Assuming that's fine, your next problem is ensuring that all of the domains use the same PHP session. You can do this by telling them all to use the same session id. Cookies are an ideal solution for this, but cookies do not work across completely different domains.
This means we have to explicitly tell checkoutdomain.com to session that we wish to load. We can force Magento to load a specific session by passing the session id as the SID GET parameter. You can get this value by calling Mage::getModel("core/session")->getEncryptedSessionId().
You should set web/session/use_frontend_sid to yes in your system configuration.
You should also keep in mind that not specifying a cookie path will make it default to the current path you are on when the cookie is set. You should default it to "/" to make sure it is being set globally for the site.

Resources