Important Notice from AspDotNetStorefront
It is with dismay that we report that we have been forced, through the action of hackers, to shut off write-access to this forum. We are keen to leave the wealth of material available to you for research. We have opened a new forum from which our community of users can seek help, support and advice from us and from each other. To post a new question to our community, please visit: http://forums.vortx.com
Results 1 to 8 of 8

Thread: Complex Category Updating

  1. #1
    cjbarth is offline Senior Member
    Join Date
    Oct 2008
    Posts
    392

    Exclamation Complex Category Updating

    If I had a category layout like the following:

    Rods/Polls
    1/2"
    3/4"
    1"

    How would I add a 1 1/2" subcategory? Every time I try I end up with:

    Rods
    Polls
    1 1
    2"

    The reason is that XPath doesn't allow the '/' character in a path and the WSI import mechanism doesn't allow the specifying the ParentEntityID.

    I tried modifying the source code of WSI.vb to include this line in the ProcessEntity function just after all the initial Dim statements:

    If ParentEntityID = 0 Then ParentEntityID = XmlCommon.XmlFieldNativeInt(node, "ParentEntityID")

    While logically that should have worked, I can't get a clean compile with the source/solution that was provided.

    Does anyone have any suggestions? It seems to me that WSI needs to be updated to allow Entity creation to support ParentEntityID.

    Chris
    Last edited by cjbarth; 02-08-2010 at 02:24 PM.

  2. #2
    cjbarth is offline Senior Member
    Join Date
    Oct 2008
    Posts
    392

    Thumbs up

    I was able to get my modification to compile and that fixed the problem. I can now specify a ParentEntityID in the WSI XML and have it populate correctly in the database. So I have set up a table to keep track of the descriptive name of the categories and the ID that is assigned to them. When I want to add or delete a child of a category with a '/' in it I do a lookup in my custom table and then specify the ID directly.

    It seems that this one line of code should be merged in to the code-base for WSI.

    If anyone has any other suggestions about how something like this could be handled without modifications to the code-base for WSI I would like to hear them.

    Chris

  3. #3
    campbelt101 is offline Member
    Join Date
    Dec 2010
    Posts
    72

    Default

    Not sure if you ever ran into the document named "ASPDNSF ERP Provider SyncV3.pdf". I don't have a link but I downloaded it from here somewhere.

    Anyways... there's a section as follows:

    To add a new category with a Name, XPath (used to specify location in the category is a
    child of another category), Description, XmlPackage, and Published value, you could use
    as follows:

    Code:
    XElement xeImport = new XElement("AspDotNetStorefrontImport", new XAttribute("Version",
    "7.1"));
    XElement xeCategory = new XElement("Entity",
    new XAttribute("Action", "Add"),
    new XAttribute("EntityType", "Category"),
    new XElement("Name", "CategoryName"),
    new XElement("XPath", "/Main Category/Sub Category/CategoryName"),
    new XElement("Description", new XCData("category description")),
    new XElement("Display",
    new XElement("XmlPackage", "entity.gridwithprices.xml.config")),
    new XElement("Published", true));
    xeImport.Add(xeCategory);
    DoIt(xeImport.ToString(SaveOptions.DisableFormatting));
    The resulting xeImport in this case would be:
    Code:
    <AspDotNetStorefrontImport Version="7.1">
    <Entity Action="Add" EntityType="Category">
    <Name>CategoryName</Name>
    <XPath>/Main Category/Sub Category/CategoryName</XPath>
    <Description><![CDATA[category description]]></Description>
    <Display>
    <XmlPackage>entity.grid.xml.config</XmlPackage>
    </Display>
    <Published>true</Published>
    </Entity>
    </AspDotNetStorefrontImport>

    I'm running into the same issue myself, and I'm about ready to test it. I agree though, it would make much more sense to be able to specify a ParentID for the entity.

  4. #4
    Ex-Jesse is offline Member
    Join Date
    Mar 2011
    Posts
    30

    Default

    When you come up with your solution, please let me know. I've found it to be a headscratcher myself.
    Last edited by Ex-Jesse; 03-30-2011 at 12:07 AM.

  5. #5
    cjbarth is offline Senior Member
    Join Date
    Oct 2008
    Posts
    392

    Default

    What is wrong with the solution presented?
    ML9.3.1.1
    SQL 2012 Express
    VS 2010
    Azure VM

  6. #6
    campbelt101 is offline Member
    Join Date
    Dec 2010
    Posts
    72

    Default

    Quote Originally Posted by cjbarth View Post
    What is wrong with the solution presented?
    I've gotten to this section of my coding and I have to admit it's a bummer than I can't just specify the Parent ID. The part I dislike is that I have to make a call (via wsi) to get the parent's xpath (if there is one).

    Just adds more communication that I'd prefer to have, but I want to ensure I have the correct XPath.

    OP, if you are still having an issue with this, I can post some VB code showing how I do this.

  7. #7
    cjbarth is offline Senior Member
    Join Date
    Oct 2008
    Posts
    392

    Default

    When I mentioned about the solution presented I guess I was referring to the modification I made to add in processing for ParentID to WSI. I agree that the XPath solution doesn't work at all. It is slow and it doesn't work with all possible names of Categories.
    ML9.3.1.1
    SQL 2012 Express
    VS 2010
    Azure VM

  8. #8
    campbelt101 is offline Member
    Join Date
    Dec 2010
    Posts
    72

    Default

    Quote Originally Posted by cjbarth View Post
    When I mentioned about the solution presented I guess I was referring to the modification I made to add in processing for ParentID to WSI. I agree that the XPath solution doesn't work at all. It is slow and it doesn't work with all possible names of Categories.

    Sorry about that. I miss read you initial post.