rytek Posted August 12, 2013 Share Posted August 12, 2013 Hello. I found that affiliates module is not working if i enable friendly urls. I think, the dispatcher is removing all custom parameters that i add on the end of friendly url. For example: i've opened this url: shop.com/category/123-item.html?aff_id=1 in shop, the target parsed url is: shop.com/category/123-item.html (without aff_id parameter), and the aff_id is not assigned to session. This is only working when i add parameters on clean domain, i.e shop.com?aff_id=1 I've tried to edit dispatcher class but i really don't know what i have to change (i think that i have to change something near preg_replace in the createUrl function, but this is live installation, and i don't wanna broke the shop). Is there a fix for that? Ah, and we are using 1.5.4.1. Thanks! Link to comment Share on other sites More sharing options...
benjamin utterback Posted August 12, 2013 Share Posted August 12, 2013 HI rytek, You are adding a custom route in Preferences>SEO URLS> Schema of URLs? Link to comment Share on other sites More sharing options...
rytek Posted August 12, 2013 Author Share Posted August 12, 2013 Thanks for fast reply. What i should add to URL schemas? I think i can add only keywords, that are listed under the fields. Is there an option to add custom optional parameter? This is our route for products (the default one): {category:/}{id}-{rewrite}{-:ean13}.html Link to comment Share on other sites More sharing options...
rytek Posted August 14, 2013 Author Share Posted August 14, 2013 Bump. http://www.inmotionhosting.com/support/edu/prestashop-15/manage-affiliates-referrers/add-affiliate-referrer I've used this how-to, and instruction from one of the comments, but it isn't working. Any idea? Thanks. Link to comment Share on other sites More sharing options...
benjamin utterback Posted August 14, 2013 Share Posted August 14, 2013 Hey, check out this thread and see if it helps. Keep me posted! http://www.prestashop.com/forums/topic/239773-affiliate-referrer-not-tracking/ Thanks Link to comment Share on other sites More sharing options...
juanmlg Posted August 15, 2013 Share Posted August 15, 2013 HI rytek, You are adding a custom route in Preferences>SEO URLS> Schema of URLs? Please, can you explain it? I have Affiliate module working with HTTP Referrer but I am not be able to get it work with Request URI Please explain a bit Link to comment Share on other sites More sharing options...
benjamin utterback Posted August 15, 2013 Share Posted August 15, 2013 Please, can you explain it? I have Affiliate module working with HTTP Referrer but I am not be able to get it work with Request URI Please explain a bit Hi, have you taken a look at the link I posted in post #5 ? That should help explain how to have it working. Link to comment Share on other sites More sharing options...
juanmlg Posted August 15, 2013 Share Posted August 15, 2013 Hi, have you taken a look at the link I posted in post #5 ? That should help explain how to have it working. I see nothing about "Request URI" in this post. Link to comment Share on other sites More sharing options...
benjamin utterback Posted August 15, 2013 Share Posted August 15, 2013 Oh okay, you are asking a different question, this thread is about the Friendly URL. it's better to stay on topic or create a new thread for a new question. Can you do that and link me to it? I will merge these posts together. Thanks! Link to comment Share on other sites More sharing options...
juanmlg Posted August 19, 2013 Share Posted August 19, 2013 Oh okay, you are asking a different question, this thread is about the Friendly URL. it's better to stay on topic or create a new thread for a new question. Can you do that and link me to it? I will merge these posts together. Thanks! I asked it here: http://www.prestashop.com/forums/topic/265904-cant-setup-the-referrers-program/page__p__1326821#entry1326821 thanks! Link to comment Share on other sites More sharing options...
rytek Posted August 21, 2013 Author Share Posted August 21, 2013 (edited) Hi Benjamin. I've checked this topic, and i didn't find solution for my problem. It doesn't matter how i configure my affiliate, it just doesn't work when i come to subpage with aff_id. It only works when i come to mainpage. Configuration of example affiliate user: All fields are blank, except Request URI Include: %aff_id=whatever% I've ever tried example configuration from one of the comments below the how-to (http://www.inmotionh...iliate-referrer). Here is url of my shop: http://audiomagic.pl If i come to: http://audiomagic.pl?aff_id=whatever presta redirects me to http://audiomagic.pl/?aff_id=whatever (adding just ending slash). And everything works fine (opened pages, registrations, orders, everything is tracked). But.. if i come to, for example: http://audiomagic.pl...aff_id=whatever Presta won't track anything. I've added some code to track request_uri (just one variable in frontcontroller and one - requ in header.tpl). But everything seems to be fine. Can I ask, in what file is that tracking module? How it works? Thanks for help. Maybe it is problem with server configuration or bad .htaccess file? Here is my .htaccess file: # .htaccess automaticaly generated by PrestaShop e-commerce open-source solution # http://www.prestashop.com - http://www.prestashop.com/forums # php_flag display_errors on # php_value output_handler ob_gzhandler AddType application/json .json AddCharset utf-8 .json php_flag zlib.output_compression On php_value zlib.output_compression_level 5 php_value max_execution_time 12000 php_value max_input_time 6000 php_value default_socket_timeout 6000 php_value mysql.connect_timeout -1 php_value memory_limit 256M php_flag magic_quotes_gpc off php_flag log_errors on php_value error_reporting 5111 php_value error_log /home/admin/domains/audiomagic.pl/PHP_errors.log SetEnv PHPRC /etc/php5/apache2/php.ini RewriteEngine on RewriteCond %{HTTP_HOST} ^www.audiomagic.pl$ [NC] RewriteRule ^(.*)$ http://audiomagic.pl/$1 [R=301,L] # ~~start~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again # .htaccess automaticaly generated by PrestaShop e-commerce open-source solution # http://www.prestashop.com - http://www.prestashop.com/forums <IfModule mod_rewrite.c> RewriteCond %{HTTP_HOST} ^audiomagic.pl$ RewriteRule . - [E=REWRITEBASE:/] RewriteRule ^api/?(.*)$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L] # Images RewriteCond %{HTTP_HOST} ^audiomagic.pl$ RewriteRule ^([a-z0-9]+)\-([a-z0-9]+)(\-[_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1-$2$3$4.jpg [L] RewriteCond %{HTTP_HOST} ^audiomagic.pl$ RewriteRule ^([0-9]+)\-([0-9]+)(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1-$2$3.jpg [L] RewriteCond %{HTTP_HOST} ^audiomagic.pl$ RewriteRule ^([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$1$2$3.jpg [L] RewriteCond %{HTTP_HOST} ^audiomagic.pl$ RewriteRule ^([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$1$2$3$4.jpg [L] RewriteCond %{HTTP_HOST} ^audiomagic.pl$ RewriteRule ^([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$1$2$3$4$5.jpg [L] RewriteCond %{HTTP_HOST} ^audiomagic.pl$ RewriteRule ^([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$1$2$3$4$5$6.jpg [L] RewriteCond %{HTTP_HOST} ^audiomagic.pl$ RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6$7.jpg [L] RewriteCond %{HTTP_HOST} ^audiomagic.pl$ RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7$8.jpg [L] RewriteCond %{HTTP_HOST} ^audiomagic.pl$ RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8$9.jpg [L] RewriteCond %{HTTP_HOST} ^audiomagic.pl$ RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9$10.jpg [L] RewriteCond %{HTTP_HOST} ^audiomagic.pl$ RewriteRule ^c/([0-9]+)(\-[\.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/c/$1$2$3.jpg [L] RewriteCond %{HTTP_HOST} ^audiomagic.pl$ RewriteRule ^c/([a-zA-Z_-]+)(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/c/$1$2.jpg [L] # AlphaImageLoader for IE and fancybox RewriteCond %{HTTP_HOST} ^audiomagic.pl$ RewriteRule ^images_ie/?([^/]+)\.(jpe?g|png|gif)$ js/jquery/plugins/fancybox/images/$1.$2 [L] # Dispatcher RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteCond %{HTTP_HOST} ^audiomagic.pl$ RewriteRule ^.*$ - [NC,L] RewriteCond %{HTTP_HOST} ^audiomagic.pl$ RewriteRule ^.*$ %{ENV:REWRITEBASE}index.php [NC,L] RewriteCond %{HTTP_HOST} ^audiomagic.eu$ RewriteRule . - [E=REWRITEBASE:/] RewriteRule ^api/?(.*)$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L] # Images RewriteCond %{HTTP_HOST} ^audiomagic.eu$ RewriteRule ^([a-z0-9]+)\-([a-z0-9]+)(\-[_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1-$2$3$4.jpg [L] RewriteCond %{HTTP_HOST} ^audiomagic.eu$ RewriteRule ^([0-9]+)\-([0-9]+)(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1-$2$3.jpg [L] RewriteCond %{HTTP_HOST} ^audiomagic.eu$ RewriteRule ^([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$1$2$3.jpg [L] RewriteCond %{HTTP_HOST} ^audiomagic.eu$ RewriteRule ^([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$1$2$3$4.jpg [L] RewriteCond %{HTTP_HOST} ^audiomagic.eu$ RewriteRule ^([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$1$2$3$4$5.jpg [L] RewriteCond %{HTTP_HOST} ^audiomagic.eu$ RewriteRule ^([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$1$2$3$4$5$6.jpg [L] RewriteCond %{HTTP_HOST} ^audiomagic.eu$ RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6$7.jpg [L] RewriteCond %{HTTP_HOST} ^audiomagic.eu$ RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7$8.jpg [L] RewriteCond %{HTTP_HOST} ^audiomagic.eu$ RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8$9.jpg [L] RewriteCond %{HTTP_HOST} ^audiomagic.eu$ RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9$10.jpg [L] RewriteCond %{HTTP_HOST} ^audiomagic.eu$ RewriteRule ^c/([0-9]+)(\-[\.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/c/$1$2$3.jpg [L] RewriteCond %{HTTP_HOST} ^audiomagic.eu$ RewriteRule ^c/([a-zA-Z_-]+)(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/c/$1$2.jpg [L] # AlphaImageLoader for IE and fancybox RewriteCond %{HTTP_HOST} ^audiomagic.eu$ RewriteRule ^images_ie/?([^/]+)\.(jpe?g|png|gif)$ js/jquery/plugins/fancybox/images/$1.$2 [L] # Dispatcher RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteCond %{HTTP_HOST} ^audiomagic.eu$ RewriteRule ^.*$ - [NC,L] RewriteCond %{HTTP_HOST} ^audiomagic.eu$ RewriteRule ^.*$ %{ENV:REWRITEBASE}index.php [NC,L] </IfModule> <IfModule mod_expires.c> ExpiresActive On ExpiresByType image/gif "access plus 1 month" ExpiresByType image/jpeg "access plus 1 month" ExpiresByType image/png "access plus 1 month" ExpiresByType text/css "access plus 1 week" ExpiresByType text/javascript "access plus 1 week" ExpiresByType application/javascript "access plus 1 week" ExpiresByType application/x-javascript "access plus 1 week" ExpiresByType image/x-icon "access plus 1 year" </IfModule> FileETag INode MTime Size <IfModule mod_deflate.c> <IfModule mod_filter.c> AddOutputFilterByType DEFLATE text/html text/css text/javascript application/javascript application/x-javascript </IfModule> </IfModule> #If rewrite mod isn't enabled ErrorDocument 404 /index.php?controller=404 # ~~end~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again Edited August 21, 2013 by rytek (see edit history) Link to comment Share on other sites More sharing options...
rytek Posted August 21, 2013 Author Share Posted August 21, 2013 Ok, i found something interesting. I've opened the _connections_source table in phpmyadmin and i've done search for %?% in request_uri column. Presta doesn't have any links with parameters after friendly url. It contains only url's with mainpage (domain). There is issue with friendly urls. This configuration is removing all _GET parameters that are added on the end of url. But I don't know where is mistake. I've generated new .htaccess, but problem did not disappear. Link to comment Share on other sites More sharing options...
emittman Posted August 30, 2013 Share Posted August 30, 2013 I had an issue just like this where using the friendly URLs didn't capture the affiliate code I was using. For me I encountered a work around by making up the affiliate links that I handed out to match the non friendly URL's. I found that adding the affiliate id to a non-friendly version of the URL for any link to my site would allow the affiliate information to be correctly recorded and give the credit where it was deserved. Here are a couple of example links for reference: user regular URL for the affilate http://site.com/index.php?id_product=53&controller=product&affiliate=10 instead of the friendly URL http://store.com/category/99-item-name.html?affiliate=10 Link to comment Share on other sites More sharing options...
rytek Posted August 30, 2013 Author Share Posted August 30, 2013 (edited) I found another solution. classes/ConnectionsSource.php, Lines 86-91: if (isset($_SERVER['REDIRECT_URL'])) $source->request_uri .= strval($_SERVER['REDIRECT_URL']); elseif (isset($_SERVER['REQUEST_URI'])) $source->request_uri .= strval($_SERVER['REQUEST_URI']); if (!Validate::isUrl($source->request_uri)) $source->request_uri = ''; Replace with: if (isset($_SERVER['REQUEST_URI'])) $source->request_uri .= strval($_SERVER['REQUEST_URI']); elseif (isset($_SERVER['REDIRECT_URL'])) $source->request_uri .= strval($_SERVER['REDIRECT_URL']); if (!Validate::isUrl($source->request_uri)) $source->request_uri = ''; It's working for me, even with friendly urls. Edited August 30, 2013 by rytek (see edit history) Link to comment Share on other sites More sharing options...
benjamin utterback Posted August 30, 2013 Share Posted August 30, 2013 I found another solution. classes/ConnectionsSource.php, Lines 86-91: if (isset($_SERVER['REDIRECT_URL'])) $source->request_uri .= strval($_SERVER['REDIRECT_URL']); elseif (isset($_SERVER['REQUEST_URI'])) $source->request_uri .= strval($_SERVER['REQUEST_URI']); if (!Validate::isUrl($source->request_uri)) $source->request_uri = ''; Replace with: if (isset($_SERVER['REQUEST_URI']) OR isset($_SERVER['QUERY_STRING']) ) $source->request_uri .= strval($_SERVER['REQUEST_URI']); elseif (isset($_SERVER['REDIRECT_URL'])) $source->request_uri .= strval($_SERVER['REDIRECT_URL']); if (!Validate::isUrl($source->request_uri)) $source->request_uri = ''; It's working for me, even with friendly urls. Hi rytek, is this a solution just for you/your server? I'm wondering if its a bug or a serious issue because a lot of people don't have an issue with this module and Friendly URL's. Link to comment Share on other sites More sharing options...
rytek Posted August 30, 2013 Author Share Posted August 30, 2013 (edited) Hi rytek, is this a solution just for you/your server? I'm wondering if its a bug or a serious issue because a lot of people don't have an issue with this module and Friendly URL's. I don't know why this did not work normally for me. I found that only with that changes my affiliates are working. I managed that the connections_source table does not contain any of the parameters, that i added in the addresses. That modification causes the data appears correctly in the request_uri field. My $_SERVER['REDIRECT_URL'] variable was the cause of this problem - it was created, but empty, so i changed order of the conditions. Oh, and i realized, that my code wasn't perfect. Checking if the QUERY_STRING variable is set is not necessary, dunno why i added that Btw, i think that i'm not the only one who have that problem - Emittman seems to have the same issue. Edited August 30, 2013 by rytek (see edit history) Link to comment Share on other sites More sharing options...
benjamin utterback Posted August 30, 2013 Share Posted August 30, 2013 Ah yes, I did not mean to say that it was purely isolated. I am trying to figure out the common cause. Could you post the updated code change (without the query string) If you could, we would really like to know your Server Configuration as well. Link to comment Share on other sites More sharing options...
rytek Posted August 30, 2013 Author Share Posted August 30, 2013 I updated code in #14. I'm using: - Apache 2.2.24 - PHP 5.2.17 What configuration files do you need? Link to comment Share on other sites More sharing options...
Recommended Posts