Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotcakes Sitemap provider doesn't support localization #269

Closed
Navilois opened this issue May 20, 2020 · 7 comments
Closed

Hotcakes Sitemap provider doesn't support localization #269

Navilois opened this issue May 20, 2020 · 7 comments

Comments

@Navilois
Copy link
Contributor

Navilois commented May 20, 2020

Describe the bug

Sitemaps generated by the productsSitemapProvider provide incorrect paths when using localized page names. The generated URLs lead to the EN-US product overview instead of the product. This is very problematic for SEO reasons.

Example:
Localized URL: https://www.sierzega.com/it-it/prodotti/vedere-i-prodotti/gr33l-cl
Sitemap URL: https://www.sierzega.com/it-it/products/product-viewer/gr33l-cl

Software Versions

  • DNN: 09.04.04
  • Hotcakes: 03.02.03

To Reproduce

Steps to reproduce the behavior:

  1. Go to https://www.sierzega.com/it-it/sitemap.aspx
  2. View page source
  3. See error

Expected behavior

productsSitemapProvider should use localized page names

Actual behavior

productsSitemapProvider uses en-us (or default language) page names

Additional context

The DNN coreSitemapProvider works fine and uses the translated pages, thus everthing but the product URLs are correct.

@Navilois
Copy link
Contributor Author

In case you don't have time for this, please point me into the right direction and I'll se if I can fix it.

@WillStrohl
Copy link
Member

I'd have to take some time to debug this to give you more specific direction, but this class is where you'd want to start.

https://github.com/HotcakesCommerce/hotcakes-commerce-core/blob/master/Libraries/Hotcakes.Commerce.Dnn/Providers/ProductsSitemapProvider.cs

@Navilois
Copy link
Contributor Author

Navilois commented May 22, 2020

I've managed to create a working localized sitemap, unfortunately it's just using my current portal locale when hitting the "Clear Cache" Button at SEO -> Sitemap Settings for all localized sitemaps.

I used HccRequestContextUtils.UpdateUserContentCulture(HccRequestContext.Current);
before

urlStoreSettings = HccRequestContext.Current.CurrentStore.Settings.Urls;

I don't know how to get the correct locale in there. DNN does it using PortalSettings.CultureCode.
See lines 54 - 62 here: https://github.com/dnnsoftware/Dnn.Platform/blob/b96c4913c6bcca688e987631a17a81ad2e61905d/DNN%20Platform/Library/Services/Sitemap/CoreSitemapProvider.cs#L54

I'll be back on it on monday. If you have any clues for me I'd be grateful of course ;)

@WillStrohl
Copy link
Member

It sounds like you're on the right path to getting this done. I'd suggest comparing what you're doing to the underlying base classes in the Hotcakes admin and front-end views to get and apply the locale.

@Navilois
Copy link
Contributor Author

Navilois commented May 25, 2020

I didn't find a good way to implement the fix within https://github.com/HotcakesCommerce/hotcakes-commerce-core/blob/master/Libraries/Hotcakes.Commerce.Dnn/Providers/ProductsSitemapProvider.cs
My preferred solution would have been to pass the locale directly at GetPageUrl to RouteHccUrl via the routeValues object.

Instead I solved it by using your HccRequestContextUtils.GetContextWithCulture() method.

I replaced

urlStoreSettings = HccRequestContext.Current.CurrentStore.Settings.Urls;

by
HccRequestContext localizedContext = HccRequestContextUtils.GetContextWithCulture(HccRequestContext.Current, CurrentPortalSettings.CultureCode);
urlStoreSettings = localizedContext.CurrentStore.Settings.Urls;

Might also be relevant for MvcHccUrlResolver @Hotcakes.Commerce.NoCms, not just DnnHccUrlResolver @Hotcakes.Commerce.Dnn.

I'm not 100% certain of the impact of this change nor do I have the automated testing capabilities. GetTabId() has a very general purpose and I have no idea, if I'm messing up something else. It seems to be working fine so far, but I didn't do a lot of testing yet.

Can you take a closer look?

This was referenced May 25, 2020
Navilois added a commit to Navilois/hotcakes-commerce-core that referenced this issue May 26, 2020
Navilois added a commit to Navilois/hotcakes-commerce-core that referenced this issue May 26, 2020
@Navilois
Copy link
Contributor Author

Navilois commented May 26, 2020

Wasn't happy with the first solution, this one is much better ;) It's simply localizing the HccRequestContext when the sitemap is generated. I did some testing - works perfectly fine and I don't see a reason this could have an unforseen negative impact.

It's live on my production environment already - e.g. https://www.sierzega.com/es-es/sitemap.xml

To be discussed:
At the moment, the provider generates URLs for all products. I prefer products that are AvailableForSale = true only, but I removed it (see commit e9733b5) again for this pull request since it might be a breaking change for some.

@WillStrohl
Copy link
Member

Really good stuff!

@WillStrohl WillStrohl modified the milestones: 03.04.00, 03.03.01 Jun 4, 2020
WillStrohl pushed a commit that referenced this issue Jun 4, 2020
Localization of Sitemaps - fixes #269
mtrutledge added a commit to mtrutledge/core that referenced this issue Sep 15, 2021
* Phone number requirement feature

* Improved string performance in store settings

* Minor typos in gift card configuration

* Removed explicit TabIndex assignments

* Removed explicit TabIndex assignments

* Resolved minor DOM warning issue with same-name elements

* Adds UPS response to diagnostic logging

* Corrects South Korea's ISO data

* Only show product sort when there is more than one option

* Resolves HotcakesCommerce#214
Filtered out expired user roles

* Resolved issues w/ radcombobox removal in all settings views

* Not showing disabled products as related items

* Assigns imported images to imported products

* Adds a scheduled task to clear temp files

* Updates to help with debugging during development

* Updated underlying build website to DNN Platform 9.2.2

* Updated DNN reference DLLs to 9.2.2

nuget to come later

* Cleaning up DNN upgrade artifacts before first build

* Successfully building against DNN 9.2.2 (no code changes necessary)

* Un-sync'd DLL from previous updates

* Resolved theme pane placement for modules during wizard config

* Replaced the base DNN package with v9.2.2

* Removing Hotcakes DLLs from tracking

* Adding missed DLLs from DNN upgrade

* Added the rest of the missing DLLs from the DNN upgrade

* Resolved build/install issues & EVS warnings

* Resolved display issues with the dashboard

* Resolves dashboard display issues

* Returning the Small product image instead of Medium

* This DLL "changed" for some reason, but it's still the same. :(

* Added admin buttons to front-end views

* Merged admin button updates to the Social Spokes viewset

* Merged admin button updates into the DevSamples

includes updates from previous commits

* Reverted mobile CSS changes

* Copied _default viewset to be available as a legacy option

* Allow viewset developers to easily create AddToCart links in views

* Able to specify a classname  to options & improved string performance

* Updated default text for the file upload

* Fixes HotcakesCommerce#269 by localizing the HccHttpContext at sitemap creation

* Fixes HotcakesCommerce#269 by localizing the HccHttpContext at sitemap creation

* removed whitespace

* Replaced the Copy to Clipboard functionality...

(removes SWF dependency)

* Localized the orders grid

* Replaced the Copy to Clipboard functionality (part two)...

(removes SWF dependency)

* Removed ability to show card numbers

* Added JS API support for HTTP/S protocol in HCC library

* Filtering user inputs in checkout & product views

* Changed the pane where the search input is added in the wizard

* Bootstrap 3 viewset as the default viewset

* Resolved display issue with additional images

* Fixed product name typo & adding tiny images

* Updated the sample product images

* Localized product choices & resolved icon display issues

* Adding HCC branding to default e-mail templates

* Improved branding for missing product/category images

* Only logging errors, not debugging

* Removed obsolete endpoints and related code

Almost all endpoints have been obsolete since v2.0 or earlier (except 2 for Evoq Social, 3.0.0).

* Resolves a non-cached page load grid issue found during testing

* Resolved BS3 viewset display issues during testing

* INitial commit for BS4 viewset (only the main category view is done)

* Deprecated Manufactures for Manufacturers

* Resolves minor issues found during testing

* Resolved minor JS bug in drilldown views

* Updated Category & Product views to BS4

* Minor viewset updates after testing

* BS4 conversion updates for the cart

* BS3 minor usability fixes from testing

* BS4 conversion updates for checkout views

* BS3 minor usability updates from testing

* BS4 conversion updates for receipt views

* BS4 conversion updates for order history views

* Enhanced visual support for payment & stock labels

* BS4 conversion updates for wish list, order history, content blocks

* BS4 conversion of the address book views

* BS4 conversion for the reviews views

* BS3 search view UX updates from testing

* BS4 conversion updates for the search views

* BS3 mobile UX updates from testing

* Resolves a bug displaying products in Product Grid settings

* Fixed sample products cupcake typo

* BS4 conversion for optional product views

* Fixed remaining typos with cupcakes & manufacturers

* Added a jQuery plugin for BS4 tabs (jQuery UI inspired)

* BS4 conversion for affiliate views

* Minor typo in BS3 viewset

* Updated missed EM tags

* Localized Receive Payments admin view

* Resolved image display issue with info tabs

* Enabled lists in the new html editor

* updated the credit card logos in all viewsets

* Release notes & versioning

* Updated DevSamples with new viewsets

* Core scripts served minified, except when DNN is in debug mode

* Final packaging updates prior to release

* Missed commits from build testing

* No actual changes. Alphabetized the properties while documenting.

* Fixes HotcakesCommerce#288

* No actual changes. Alphabetized the properties while documenting.

* Only show available products @sitemap

* Added a Porto5 viewset

This is not compatible with the Category Drilldown and Affiliate views

* Added Porto5 viewset to the build and install process

* removing the test project from the solution build

* BS4 Only show one of the shopping cart buttons w/ empty wish list

* BS4: Resolved display issue w/ cart header

* BS4 Checkout login label usability updates

* BS4 Product details corrected margin class

* BS4 Product details ensured label formatting is consistent

* BS4 prevent search engines from following add to cart links & 

using built-in cart routing method

* BS4 present search engines from following add to cart links

* Build and environment restoration artifacts

* No actual changes. Alphabetized the properties while documenting.

* Resolves sort order issue with displayed facets

* String optimizations to improve performance

* Final packaging updates for build

* Merged viewset updates into the DevSamples

* Updated the references in DevSamples

* Fixed typos in the release notes

* Typo and localization updates in the default template

* Resolves HotcakesCommerce#294

* Prep for 03.04.01 release

* Revert "Only show available products @sitemap"

This reverts commit 506cf6b.

* Basic solution for this enhancement - needs refining and polishing

* Changed Checkout.js to default-Legacy to match dev.env - Reset on invalid vat now takes the products TaxExempt value.

* Localized validation msg

* Provide Sitemap-URLs of active products only

* All Controllers: changed every occurrence of Response.Redirect to Redirect

* Adding support for submit type button elements to forms

* Closes HotcakesCommerce#313

Closes HotcakesCommerce#313

* data source update

* Updated .NET to 4.7.2 & DNN to 9.4.4

* Resolving build issues

* Initial addition of Prompt

* Moved localization to base class

* Added HCC branding to messages

* Added sales summary prompt

* Added a clear cache prompt

* Prevent a conflict with built-in prompt command

* Localized prompt descriptions

* Added logging to DNN user creation tasks

* Added a flag to sales-summary

* Fixed bug in Viewsets

* Bug Fix for api timeout

* Adds more logging to the DNN Membership workflow task

* Placeholder content for help for prompt commands

* Merge PR HotcakesCommerce#304 updates to the DevSamples

* Merged PR HotcakesCommerce#304 missing updates to the other viewsets

* Fix in SQL

* Fixed folder structure for DevSamples viewsets

* Resolves HotcakesCommerce#322

* Alphabetized the properties

* Resolves HotcakesCommerce#311

* Resolved domain name typos

* Updated the version for packaging

* Updated release notes for packaging

* Fix in Provider Script

* Resolves build issues

* Resolves build issues

* More Fix in Store Settings SQL script

* Updated release notes

* Preventing file locks during build

* Moved new store settings logic from SQL to IUpgradeable

* Resolves issue with incorrect key store setting on upgrade

* Replaced interpolation with string.Format for now

* Bug fix for JS issue in viewset

* Fixed issue in JS  for emails

* Merged viewset changes

* more bug fix in JS for viewsets

* Removed deprecated licensing DLL reference

* Was supposed to be building against DNN 9.2.2 not 9.4.4

* Formally removing HCC licensing on upgrade

* Updating DevSamples references

* Removed unnecessary PDB

* Resolved final build issues in DevSamples

* Updated Stripe to use Newtonsoft.Json 10.0.3

* Properly updated DevSample DLLs to 3.5.0

* Paypal Express Hold Authorization issue

A Paypal hold could fail due to end user's lack of funds or linked account. If this happens, the Paypal Express Hold should return a fail, not a success.

* Cancels Button Postback for Generate Url and Copy Url to allow user to use the links that were just generated

* Using the OrderTaskContext.Order.OrderNumber as a fallback in case the OrderNumber on the OrderTransaction object is an empty string

* Checks the RedirectResult from the HandleActionParams() and if it's something other than the Cart page, it redirects, otherwise it continues with loading the Shopping Cart

* Remove GB from EU VAT rules

Co-authored-by: Will Strohl <hismightiness@users.noreply.github.com>
Co-authored-by: Will Strohl <will@upendoventures.com>
Co-authored-by: Paras Daryanani <paras@celestialsites.com>
Co-authored-by: Navilois <a.krichmayr@gmail.com>
Co-authored-by: William Benz <william.a.benz@gmail.com>
Co-authored-by: Nirav <sniravj@gmail.com>
Co-authored-by: Scott Wilkinson <swilkinson@blueboltsolutions.com>
Co-authored-by: joshgk00 <josh@clicksandmortarwebsites.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants