Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Clean urls 5.2.3

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #11  
Old 04-30-2015, 03:39 AM
  tony_sologubov's Avatar 
tony_sologubov tony_sologubov is offline
 

X-Cart team
  
Join Date: Jan 2009
Posts: 2,431
 

Default Re: Clean urls 5.2.3

I just went to try to apply this change and found out that you need to apply two changes:
1) In your database, you must change product seo-friendly URLs, so they would be without an extension
2) Then, you should decorate the parseURLProduct() method in the \XLite\Model\Repo\CleanURL class, so it would check for URLs even if URL is without extension.

Please, let me know if it helps.

Tony
__________________
Found a bug in X-Cart? Post it to our bug tracker!
Know how to make X-Cart better? Suggest an idea!
Reply With Quote

The following user thanks tony_sologubov for this useful post:
Phil Richman (07-29-2015)
  #12  
Old 07-08-2015, 09:22 AM
 
Phil Richman Phil Richman is offline
 

Advanced Member
  
Join Date: May 2012
Posts: 94
 

Default Re: Clean urls 5.2.3

Quote:
Originally Posted by tony_sologubov
I just went to try to apply this change and found out that you need to apply two changes:
1) In your database, you must change product seo-friendly URLs, so they would be without an extension
2) Then, you should decorate the parseURLProduct() method in the \XLite\Model\Repo\CleanURL class, so it would check for URLs even if URL is without extension.

Please, let me know if it helps.

Tony
I still haven't been able to get this to work. Can you give me so more advice on how exactly you decorated your parseURLProduct() method to make this work. I haven't had any luck with this.
__________________
Ver 5.2.6
Reply With Quote
  #13  
Old 07-10-2015, 06:08 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default Re: Clean urls 5.2.3

Hello Phil,

Here are the changes that will likely work for you (I haven't tested them):
Code:
Index: src/classes/XLite/View/Model/Product.php =================================================================== --- src/classes/XLite/View/Model/Product.php (revision 10dbbaaf6ca1841223f0539430993ba9db3c3b51) +++ src/classes/XLite/View/Model/Product.php (revision ) @@ -160,7 +160,6 @@ \XLite\View\FormField\Input\Text\CleanURL::PARAM_OBJECT_CLASS_NAME => 'XLite\Model\Product', \XLite\View\FormField\Input\Text\CleanURL::PARAM_OBJECT_ID_NAME => 'product_id', \XLite\View\FormField\Input\Text\CleanURL::PARAM_ID => 'cleanurl', - \XLite\View\FormField\Input\Text\CleanURL::PARAM_EXTENSION => \XLite\Model\Repo\CleanURL::CLEAN_URL_DEFAULT_EXTENSION, ), ); Index: src/classes/XLite/Model/Repo/CleanURL.php =================================================================== --- src/classes/XLite/Model/Repo/CleanURL.php (revision 10dbbaaf6ca1841223f0539430993ba9db3c3b51) +++ src/classes/XLite/Model/Repo/CleanURL.php (revision ) @@ -122,7 +122,7 @@ */ protected function getPatternProduct() { - return $this->getCommonPattern() . '(\.' . static::CLEAN_URL_DEFAULT_EXTENSION . ')?'; + return $this->getCommonPattern(); } // }}} @@ -469,7 +469,7 @@ */ protected function postProcessURLProduct($url, $entity) { - return $url . '.' . static::CLEAN_URL_DEFAULT_EXTENSION; + return $url; } // }}} @@ -559,15 +559,9 @@ */ protected function parseURLProduct($url, $last = '', $rest = '', $ext = '') { - $result = null; - - if ($ext) { - $result = $this->findByURL('product', $url . $ext); + return $this->findByURL('product', $url); - } + } - return $result; - } - /** * Parse clean URL * Return array((string) $target, (array) $params) @@ -864,7 +858,7 @@ $product = \XLite\Core\Database::getRepo('XLite\Model\Product')->find($params['product_id']); if (null !== $product && $product->getCleanURL()) { - $urlParts[] = $product->getCleanURL(); + $urlParts[] = $product->getCleanURL() . '/'; } }

Minuses are the lines that you should remove. Pluses are the lines that you should add.

Plus, if you have Reviews module, you should update the Repo\CleanURL class i that module.
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote

The following user thanks qualiteam for this useful post:
Phil Richman (07-29-2015)
  #14  
Old 07-10-2015, 11:39 AM
 
Phil Richman Phil Richman is offline
 

Advanced Member
  
Join Date: May 2012
Posts: 94
 

Default Re: Clean urls 5.2.3

Quote:
Originally Posted by qualiteam
Hello Phil,

Here are the changes that will likely work for you (I haven't tested them):
Code:
Index: src/classes/XLite/View/Model/Product.php =================================================================== --- src/classes/XLite/View/Model/Product.php (revision 10dbbaaf6ca1841223f0539430993ba9db3c3b51) +++ src/classes/XLite/View/Model/Product.php (revision ) @@ -160,7 +160,6 @@ \XLite\View\FormField\Input\Text\CleanURL::PARAM_OBJECT_CLASS_NAME => 'XLite\Model\Product', \XLite\View\FormField\Input\Text\CleanURL::PARAM_OBJECT_ID_NAME => 'product_id', \XLite\View\FormField\Input\Text\CleanURL::PARAM_ID => 'cleanurl', - \XLite\View\FormField\Input\Text\CleanURL::PARAM_EXTENSION => \XLite\Model\Repo\CleanURL::CLEAN_URL_DEFAULT_EXTENSION, ), ); Index: src/classes/XLite/Model/Repo/CleanURL.php =================================================================== --- src/classes/XLite/Model/Repo/CleanURL.php (revision 10dbbaaf6ca1841223f0539430993ba9db3c3b51) +++ src/classes/XLite/Model/Repo/CleanURL.php (revision ) @@ -122,7 +122,7 @@ */ protected function getPatternProduct() { - return $this->getCommonPattern() . '(\.' . static::CLEAN_URL_DEFAULT_EXTENSION . ')?'; + return $this->getCommonPattern(); } // }}} @@ -469,7 +469,7 @@ */ protected function postProcessURLProduct($url, $entity) { - return $url . '.' . static::CLEAN_URL_DEFAULT_EXTENSION; + return $url; } // }}} @@ -559,15 +559,9 @@ */ protected function parseURLProduct($url, $last = '', $rest = '', $ext = '') { - $result = null; - - if ($ext) { - $result = $this->findByURL('product', $url . $ext); + return $this->findByURL('product', $url); - } + } - return $result; - } - /** * Parse clean URL * Return array((string) $target, (array) $params) @@ -864,7 +858,7 @@ $product = \XLite\Core\Database::getRepo('XLite\Model\Product')->find($params['product_id']); if (null !== $product && $product->getCleanURL()) { - $urlParts[] = $product->getCleanURL(); + $urlParts[] = $product->getCleanURL() . '/'; } }

Minuses are the lines that you should remove. Pluses are the lines that you should add.

Plus, if you have Reviews module, you should update the Repo\CleanURL class i that module.
It comes up with the right formatting for the product url, but it still gives a 404 error. I can get the page to come up if I add the .html extension back in manually in the address bar, but it won't find the page with out it. Any ideas where to look next?
__________________
Ver 5.2.6
Reply With Quote
  #15  
Old 07-13-2015, 11:56 PM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default Re: Clean urls 5.2.3

I guess the links in the xc_clean_urls table should be without .html endings too.
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote
  #16  
Old 07-14-2015, 04:17 AM
 
Phil Richman Phil Richman is offline
 

Advanced Member
  
Join Date: May 2012
Posts: 94
 

Default Re: Clean urls 5.2.3

Quote:
Originally Posted by qualiteam
I guess the links in the xc_clean_urls table should be without .html endings too.

I checked that. The clean url is in the table both ways.
__________________
Ver 5.2.6
Reply With Quote
  #17  
Old 07-29-2015, 09:15 AM
 
Phil Richman Phil Richman is offline
 

Advanced Member
  
Join Date: May 2012
Posts: 94
 

Default Re: Clean urls 5.2.3

I'm stumped on this. xcart is generating the links in the right format, but when you click on them you end up with a 404 error. If you add .html to the end of the url it will find the pages. Any body have any thoughts or suggestions?
__________________
Ver 5.2.6
Reply With Quote
  #18  
Old 07-29-2015, 09:31 AM
 
Phil Richman Phil Richman is offline
 

Advanced Member
  
Join Date: May 2012
Posts: 94
 

Default Re: Clean urls 5.2.3

I just noticed that I can add ."anything" and it will work. It doesn't have to be .html or .htm. As long as it has . followed by any text string it will work. If this makes sense to anyone.
__________________
Ver 5.2.6
Reply With Quote
  #19  
Old 07-29-2015, 09:43 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default Re: Clean urls 5.2.3

Unfortunately, it's hard to guess what may happen.
You'll have to debug it step by step by editing files in the /var/run/ directory (so you don't have to re-deploy the store after every change).

You may use \XLite\Logger::logCustom('debug', var_export(array($var1,$var2,...), true)); to save variables that you want to check into the /var/log/debug.log file - this may help you to check variables in places where var_dump() doesn't work (where its output doesn't go to the browser).
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote

The following user thanks qualiteam for this useful post:
Phil Richman (07-29-2015)
  #20  
Old 07-29-2015, 03:31 PM
 
Phil Richman Phil Richman is offline
 

Advanced Member
  
Join Date: May 2012
Posts: 94
 

Default Re: Clean urls 5.2.3

Thanks for all of your help. I think I finally have it working like I wanted.
__________________
Ver 5.2.6
Reply With Quote

The following user thanks Phil Richman for this useful post:
qualiteam (07-30-2015)
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 03:07 PM.

   

 
X-Cart forums © 2001-2020