Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


These support forums are now closed for new topics and comments.
Please head on over to http://eureka.ucommerce.net/ for support.

  • Eran Meir 401 posts 543 karma points
    Jul 11, 2011 @ 12:47
    Eran Meir
    0

    some questions

    hey, i'm new to uCommerce, and i'm in the middle of trying to understand how uCommerce works.
    i've tried to find editor manual for uCommerce, but couldn't find one, too bad. 

    1. i'll start with defintions, why do i need category defintion and how it helps me? (example will be helpful)
    2. let's say i want to display with linq the roots categories, what is the correct way to do it ?
    3. i created some categories and then deleted them by deleting the root category. now i try to create a categoy with a name of a category that i already deleted but it tells me "Name already exists within catalog.", what can i do ?

    thank you.
    Eran.

  • Anders Lund 17 posts 38 karma points
    Jul 12, 2011 @ 14:44
    Anders Lund
    0

    Hi Eran

    First, there is not that much structured documentation on uCommerce yet. The best ressources will definately be:

    The category- and productdefinitions are very handy for structuring your data for your shop. Think of them as documenttypes in Umbraco. You can build different data-definitions for your different products and productgroups. Properties could fx. be header, short desciption, image, title-tag, meta-description etc. You can always extend your list of definitions and their properties in the future, but be sure that you structure your definitions correct and select the right definitions for your products and productgroups when you create those.

    About listing the root categories you should use the uCommerce API. Example:

    foreach (var category in Category.All().Where(x => x.ProductCatalog.Name == catalogName)) 
    {
    IUrlService urlService = ObjectFactory.Instance.Resolve<IUrlService>();
    ProductCatalog catalog = ProductCatalog.SingleOrDefault(x => x.Name == catalogName);
    string categoryUrl = urlService.GetUrl(catalog, category);

    string umbracoFile = string.Empty;

    var media = uQuery.GetMedia(@category.ImageMediaId.ToString());

    if (media != null)
    {
    umbracoFile = media.getProperty("umbracoFile").Value.ToString();
    }

    <li>
    <div>
    <a href="@categoryUrl"><img src="@umbracoFile" alt="" /></a>
    </div>
    <h2><a href="@categoryUrl">@category.Name</a></h2>
    </li>
    }

    hmm...  the last one about deleting the root...  I guess it has something to do with a unique constraint in the database. And the category will proberbly not actually get deleted, it will just have a "deleted-flag" set. I think you should navigate to the record en the db an remove the deleted-flag, and then thats it. Not the most beatyfull solution, and i guess it could be considered as a bug.

    Regards
    Anders

  • Eran Meir 401 posts 543 karma points
    Jul 13, 2011 @ 10:25
    Eran Meir
    0

    thank you for your answers.
    about the root categories i found out about Category.GetRootCategories and i got the following code

    @using UCommerce.EntitiesV2;
    @{
        ICollection<Category> rootCategories = Category.GetRootCategories(ProductCatalog.Get(24));
        <ul>
        @foreach (var rootCategory in rootCategories)
        {
            <li>@rootCategory.Name</li>
        }
        </ul>
    }

    i want to improve the code and get the first catalog and not count on Id or Name of the catalog, how can i do it ?
    about the bug, your advice about the deleted flag fixed it :) 

  • Anders Lund 17 posts 38 karma points
    Jul 13, 2011 @ 10:51
    Anders Lund
    1

    Hi Eran

    If you want to pick just the first catalog, then this should do it:

    ProductCatalog.FirstOrDefault(x => true);

    Pretty generic, but not the best solution if you suddenly end up with more than one catalog in your solution.

    You usually identify your catalogs by name. So a better way in my opinion is to use something like this:

    string catalogName = "my catalog name from somewhere... could be from the hosting Umbraco"; 
    ProductCatalog myCatalog = ProductCatalog.FirstOrDefault(x => x.Name == catalogName);
  • Eran Meir 401 posts 543 karma points
    Jul 13, 2011 @ 11:09
    Eran Meir
    0

    i decided to go with your advice and get the catalog by the name.

    thank you for your help !!

  • Christian Wendler 46 posts 155 karma points
    Jul 22, 2011 @ 17:27
    Christian Wendler
    0

    I like to add that you also should keep an eye on Lasse's blog (he's the other guy behind uCommerce):

    http://blog.lasseeskildsen.net/

    Bye

    Christian

Please Sign in or register to post replies

Write your reply to:

Draft