XML Sitemap being created in wrong directory

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
JimFriend
Ensign (ENS)
Ensign (ENS)
Posts: 10
Joined: Thu Jul 05, 2007 1:31 pm
Contact:

XML Sitemap being created in wrong directory

Post by JimFriend » Mon Dec 28, 2009 4:40 pm

So I originally I had a multi-store setup working where two stores shared the same database. That was working fine, but my client wanted to split the sites in the end so that he had two sites running on two separates databases. I accomplished this fine. Everything is working as I would expect it to except for the XML Sitemap functionality. For some reason, when I create the XML Sitemap on the secondary site (we'll call it Site B) the actual file is created in Site A's root directory. The information inside of the file is correct (it has Site B's info) -- it's just where the file is created that is the problem.

The code that handles the sitemap creation hasn't been touched at all on either site (/Admin/Website/CommonXLMSitemap). So I'm assuming the problem is that there is some leftover setting somewhere (web.config? database field? somewhere else?) that is causing the sitemap for Site B to be created in the root directory of Site A instead of Site B's root directory.

The situation is a bit confusing so if I need to do a better job of explaining please let me know.

Thanks in advance.
Jim Friend
Web Developer
Image

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: XML Sitemap being created in wrong directory

Post by mazhar » Tue Dec 29, 2009 3:36 am

I am not sure but try following and see what happens. First take backup of you Admin/Website/CommonXMLSiteMap.aspx.cs file and then locate following code

Code: Select all

options.DefaultUrlPriority = AlwaysConvert.ToDecimal(DefaultUrlPriority.Text);
update it as

Code: Select all

options.DefaultUrlPriority = AlwaysConvert.ToDecimal(DefaultUrlPriority.Text);
        string path = Server.MapPath(Token.Instance.Store.StoreUrl);
        if(!path.EndsWith("\\"))
            path+="\\";
        options.SiteMapDataPath = path;
Now again generate the sitemap and see where it goes.

JimFriend
Ensign (ENS)
Ensign (ENS)
Posts: 10
Joined: Thu Jul 05, 2007 1:31 pm
Contact:

Re: XML Sitemap being created in wrong directory

Post by JimFriend » Tue Dec 29, 2009 7:07 am

Thanks for the quick reply, mazhar.

I tested out the above code and this is what I found:

First, there are two spots where "options.DefaultUrlPriority = AlwaysConvert.ToDecimal(DefaultUrlPriority.Text);" shows up. It shows up once in GetPostedOptions() and once in initializeControls(). I tried your code in both spots and got this initial error:

'http://www.mydomainhere.com/' is not a valid virtual path.

So instead of using: string path = Server.MapPath(Token.Instance.Store.StoreUrl);

I changed it to: string path = "http://www.mydomainhere.com";

but I still got an error saying that URI's aren't supported.

Any other ideas?
Jim Friend
Web Developer
Image

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: XML Sitemap being created in wrong directory

Post by mazhar » Tue Dec 29, 2009 7:10 am

Give to by changing path to simply "~/"

JimFriend
Ensign (ENS)
Ensign (ENS)
Posts: 10
Joined: Thu Jul 05, 2007 1:31 pm
Contact:

Re: XML Sitemap being created in wrong directory

Post by JimFriend » Tue Dec 29, 2009 7:42 am

I tried changing it to "~/" like you suggested but still got an error.

So I tried hardcoding the path in and it worked correctly. Obviously this isn't ideal because if anything changes or if they move the site it will error, but for now it's working at least.
Jim Friend
Web Developer
Image

cunningham
Ensign (ENS)
Ensign (ENS)
Posts: 2
Joined: Sat Jan 09, 2010 12:18 pm

Re: XML Sitemap being created in wrong directory

Post by cunningham » Sat Jan 09, 2010 12:54 pm

Since you have two different databases now, can you change it on Site B?

Code: Select all

SELECT *
FROM ac_StoreSettings
WHERE FieldName = 'CommonSiteMap_SiteMapDataPath'

afm
Captain (CAPT)
Captain (CAPT)
Posts: 339
Joined: Thu Nov 03, 2005 11:52 pm
Location: Portland, OR
Contact:

Re: XML Sitemap being created in wrong directory

Post by afm » Sat Jan 09, 2010 6:08 pm

If you have access to the database, delete the value for CommonSiteMap_SiteMapDataPath in the ac_StoreSettings table. Then go to the Site Map page in admin and save the settings (you don't have to change anything). That will force the path to be recalculated.
Andy Miller
Structured Solutions

Shipper 3 - High Velocity Shipment Processing

Post Reply