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.

  • Sasmita Rout 6 posts 26 karma points
    Sep 13, 2012 @ 11:41
    Sasmita Rout
    0

    Cant able to Display Product Catalog Group and Product Catalog while creating through programmatically

     

    I'm trying to create Product Catalog Group ,Product Catalog,Category and Product through programmatically using API,I am able to store these details in data base,but these details is not displaying in uCommerce site. What am I missing here?

  • Søren Spelling Lund 1797 posts 2786 karma points
    Sep 17, 2012 @ 11:23
    Søren Spelling Lund
    0

    Hi Sasmita,

    Are they not showing up in the backend or the frontend?

    When dealing with the backend remember that everything has permissions assigned to them. If the user logged into the backend doesn't have permission to see a particular store or catalog they'll not show up.

    You can assign permissions to new objects by using the RoleService class like so:

    var roleService = ObjectFactory.Instance.Resolve<IRoleService>();
    var roles = roleService.GetAllRoles().ToList().Where(x => x.Allows(entity));
    // Assigns to current user, but you can look up any user using the IUserService roleService.AddUserToRoles(securityService.GetCurrentUser(), roles.ToList());
  • Sasmita Rout 6 posts 26 karma points
    Sep 19, 2012 @ 08:19
    Sasmita Rout
    0

    Thanks a lot Soren for replying me.I am not able to display it on frontend ,but am able store in backend 

  • Sasmita Rout 6 posts 26 karma points
    Sep 19, 2012 @ 12:11
    Sasmita Rout
    0
     I've created a new ProductCatalog (using the API), and looking in the uCommerce_ProductCatalog table, it's there and just like the default one. So is there something else I should create to make this catalog visible in the back-office uCommerce tree? And i tried with above sample  code  assign permissions to new objects ,now am able to diplay the Product Catalog Group  ,but not the Product catlog.
    Below is the my code details,please suggest what am I missing here
     var productCatalogGroup = new ProductCatalogGroup { Name = dr[DataTableColumnName.ProductCatalogGroup].ToString().Trim(), EmailProfile = emailProfileId, Currency = currencyId, Deleted = false, OrderNumberSerie = ordernumberId }; if (productCatalogGroupExists == null) { productCatalogGroup.Save(); } // Saving Product Catalog var priceGroupId = PriceGroup.SingleOrDefault(x => x.Name == "EUR 15 pct"); var productCatalogGroupToSave = ProductCatalogGroup.SingleOrDefault(x => x.Name == dr[DataTableColumnName.ProductCatalogGroup].ToString().Trim() && x.Deleted == false); var productCatalogExists = ProductCatalog.SingleOrDefault(x => x.Name == dr[DataTableColumnName.ProductCatalog].ToString().Trim() && x.Deleted == false && x.ProductCatalogGroupId == productCatalogGroupToSave.ProductCatalogGroupId); var productCatalog = new ProductCatalog { Name = dr[DataTableColumnName.ProductCatalog].ToString().Trim(), ProductCatalogGroup = productCatalogGroupToSave, PriceGroup = priceGroupId, CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, DisplayOnWebSite = false, Deleted = false }; if (productCatalogExists == null) { productCatalog.Save(); } IRoleService roleService = ObjectFactory.Instance.Resolve<IRoleService>(); IUserService userservice = ObjectFactory.Instance.Resolve<IUserService>(); SecurityService securityService = new SecurityService(roleService, userservice); var roles = roleService.GetAllRoles().ToList().Where(x => x.Allows(productCatalogGroup)); var roles1 = roleService.GetAllRoles().ToList().Where(x => x.Allows(productCatalog)); 
  • Søren Spelling Lund 1797 posts 2786 karma points
    Sep 24, 2012 @ 09:40
    Søren Spelling Lund
    0

    The frontend does not enforce permissions so you can safely disregard my reply on setting permissions programatically.

    Could you check whether the "Deleted" property of the objects you are creating is set to true or false. (You want it to be false for it to show up).

    Also are you using Razor or XSLT to create the frontend?

  • Sasmita Rout 6 posts 26 karma points
    Sep 25, 2012 @ 07:25
    Sasmita Rout
    0

    Hi Soren,

    I'm working on doing a bulk import,I've got the import working, creating categories etc. (they're in the database), but nothing new shows up in the tree in the uCommerce section, even after restarting the site .

    What could I be missing? I've created a new ProductCatalog (using the API), and looking in the uCommerce_ProductCatalog table, it's there and just like the default one. So is there something else I should create to make this catalog visible in the back-office uCommerce tree?

    As u said this issue can be solved by setting permissions to new objects by using the RoleService class,i did the same thing and now am able to see the ProductCatlogGroup,but still it is not displaying  ProductCatalog and other child node...

    In this below code insteated of entity i passed ProductCatlogGroup  object,plz suggest what can i do for ProductCatalog and other child node ,and what is this entity here?

    var roleService =ObjectFactory.Instance.Resolve<IRoleService>();
    var roles = roleService.GetAllRoles().ToList().Where(x => x.Allows(entity));
    // Assigns to current user, but you can look up any user using the IUserService
    roleService
    .AddUserToRoles(securityService.GetCurrentUser(), roles.ToList());

     

     

    Thanks,
    Sasmita

  • Søren Spelling Lund 1797 posts 2786 karma points
    Sep 26, 2012 @ 10:24
    Søren Spelling Lund
    0

    You can do the same for product catalog.

    You need to assign permissions to both the store and the catalog to have them show up in the backend.

    Currently the code only assigns permissions to a single user. If you don't want to worry about permissions at all you can assign permission to the new objects to all users like so:

    var roleService = ObjectFactory.Instance.Resolve<IRoleService>();
    var userService = ObjectFactory.Instance.Resolve<IUserService>();
    
    // Grab all users so we can assign new permissions
    // to everyone. var users = userService.GetAllUsers();
    // Grab any roles for catalog and catalog group var rolesForCatalogAndCatalogGroup = roleService.GetAllRoles().ToList().Where(x => x.Allows(catalog) || x.Allows(catalogGroup)); // Assigns permission to roles to every user foreach (var user in users) { roleService.AddUserToRoles(user, rolesForCatalogAndCatalogGroup.ToList()); }
    Hope this helps.
  • Sasmita Rout 6 posts 26 karma points
    Sep 27, 2012 @ 08:59
    Sasmita Rout
    0

    Hi Soren,

    I did the same thing for Product Catlog,still am not able to make  catalog visible in the back-office uCommerce tree,plz any other suggestions?

     

    Thanks

    Sasmita

  • Søren Spelling Lund 1797 posts 2786 karma points
    Oct 01, 2012 @ 11:42
    Søren Spelling Lund
    0

    Is the code running without any exceptions?

    Does the product catalog have a ProductCatalogGroup set on it?

    Could you check umbracoLog for any errors?

  • Sasmita Rout 6 posts 26 karma points
    Oct 03, 2012 @ 08:13
    Sasmita Rout
    0

    Hi Soren,

    Yes code is running without any exceptions and product catalog have a ProductCatalogGroup  on it.Yes i checked umbracoLog,there is no error.

     

    Thanks

    Sasmita

  • Søren Spelling Lund 1797 posts 2786 karma points
    Oct 10, 2012 @ 08:57
    Søren Spelling Lund
    0

    A different approach is to disable the securty system altogether. uCommerce 3 has a option to turn it off, but for version 2 you need to override the ISecurityService. Basically what you do is implement a different version of ISecurityService that always allows the user to see objects and always returns true when UserIsInRole is called.

    When you're done with the service you need to register it in the the components.config file replacing the existing version.

Please Sign in or register to post replies

Write your reply to:

Draft