New Products Sample - Not Complete? - Front- & Back-End Development - Front- & Back-End Development - Progress Community
 Front- & Back-End Development

New Products Sample - Not Complete?

  • New Products Sample - Not Complete?
  • Hi There,

    I just started to look at the code for the new Products module and noticed that there are references to "News" all over the place. Obviously this sample was based on the built in News module but it would appear that what was included is far from being converted over. The references to "news" in comments in the code isn't a big deal but there are many other places where it's pointing to News ascx templates (that aren't provided i.e. internal const string titlesOnlyLayoutTemplateName = "Telerik.Sitefinity.Resources.Templates.Frontend.News.TitlesOnlyListView.ascx"; in the file MasterListView.cs) and things like:
    static ProductItem()
        // set default values
        permissionsetObjectTitleResKeys = new Dictionary<string, string>()
        
             ProductsConstants.Security.PermissionSetName, "NewsActionPermissionsListTitle"
        ;
    Which I would think could even possibly cause conflicts using the name name for keys in both modules? 

    As I said I'm just starting to look into this but I'm not going to waste any more of my time if this is actually not completed or the wrong code was included in the release. Can someone from Telerik clarify so we know if this is as good as it gets or if there's a cleaner version on the way.

    Thanks,
    Phill
  • Hello Phill Hodgkinson,

    The products module is complete, but, as you can see, there are things that are not cleared yet.

    ISecuredObject.PermissionsetObjectTitleResKeys is not yet documented. It is used like this:

    Since the "General" permission set is widely used for different items, one might want to differentiate them in the UI. For example, in the "permissions" dialog, one might want to see "View this blog" instead of just "View".

    The "syntax" of permissionsetObjecTitleKeys is something like

         "Supported permission set name": "Key in SecurityResources"

    The key is looked up in SecurityResources and replaced like "View/edit/modify/create this 0".

    Since the products module defines its own resources for security actions (see ProductsModule.InstallCustomPermissions and look up "ViewProducts" in ProductsResource), you can leave permissionsetObjecTitleKeys as either empty or null.

    Kind regards,
    Dido
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  • Hi,

    We have already implemented several modules based on the Products module. Most of the things work fine, except the Taxonomies. They are just not working.
    If you add a Category or Tag to a product item, but it is not saved or loaded.
    Also the filters by taxonomy is not working.

    //Kiril
  • Hi,

    I tried to run the sitefinity website in sdk example solution and I'm getting an exception from ProductManager.GetManager(string providerName) function. I debuged and found that providerName parameter is an empty string, not sure if this is the problem. Can some one help me to get this working. I want to develop a custom module and first want to see how the products module is implemented and working.

    one other thing is...i changed the app.config of the products module to point to the correct database instance in my working environment.

    Exception type: TargetInvocationException.
    Inner Message: Field 'UrlName_' of class 'Telerik.Sitefinity.GenericContent.Model.Content' is described as compiled and artificial at the same time. --> Telerik.Sitefinity.Model, Version=4.0.1098.0, Culture=neutral, PublicKeyToken=b28c218413bdf563/namespace[Telerik.Sitefinity.GenericContent.Model]/class[Telerik.Sitefinity.GenericContent.Model.Content]/field[UrlName_]

    Also this exception....

    Persistence-capable-superclass 'Telerik.Sitefinity.GenericContent.Model.Content' not declared in meta data. --> ProductCatalogSample, Version=1.0.4036.18724, Culture=neutral, PublicKeyToken=null/namespace[ProductCatalogSample.Model]/class[ProductCatalogSample.Model.ProductItem]

    Thanks!
  • I have managed to fix one of the issues
    - Tags and Categories are now saved
    Here is how:
    The module installer doesn't call InstallTaxonomies method on a installation where the previousSystemVersion is different from 0 (Thank you Reflector!)
    This becomes the end of the 
    public override void Install(SiteInitializer initializer)

    this.InstallCustomWorkflow(initializer);
    this.InstallCustomPermissions();
    this.InstallTaxonomies(initializer);

    But even when the InstallTaxonomies is called the Taxonomies are not saved for some reason.
    so InstallTaxonomies becomes 
    protected override void InstallTaxonomies(SiteInitializer initializer)
        base.InstallTaxonomy(initializer, typeof(CaseStudy));
        initializer.Context.MetadataManager.SaveChanges(false);

    This creates the metadata fields for Categories and Tags to the Model

    This still doesn't resolve the problem with Filtering the the Custom item by Category or Tag

    //Kiril
  • I am getting the same error as Duneel when I try to reuse the Product Module (inheriting it). I think I hosed the database. Any idea what this could be from?

    Server Error in '/' Application.

    Field 'UrlName_' of class 'Telerik.Sitefinity.GenericContent.Model.Content' is described as compiled and artificial at the same time. --> Telerik.Sitefinity.Model, Version=4.0.1098.0, Culture=neutral, PublicKeyToken=b28c218413bdf563/namespace[Telerik.Sitefinity.GenericContent.Model]/class[Telerik.Sitefinity.GenericContent.Model.Content]/field[UrlName_]

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: Telerik.OpenAccess.Exceptions.MetadataException: Field 'UrlName_' of class 'Telerik.Sitefinity.GenericContent.Model.Content' is described as compiled and artificial at the same time. --> Telerik.Sitefinity.Model, Version=4.0.1098.0, Culture=neutral, PublicKeyToken=b28c218413bdf563/namespace[Telerik.Sitefinity.GenericContent.Model]/class[Telerik.Sitefinity.GenericContent.Model.Content]/field[UrlName_]

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:

    [MetadataException: Field 'UrlName_' of class 'Telerik.Sitefinity.GenericContent.Model.Content' is described as compiled and artificial at the same time. --> Telerik.Sitefinity.Model, Version=4.0.1098.0, Culture=neutral, PublicKeyToken=b28c218413bdf563/namespace[Telerik.Sitefinity.GenericContent.Model]/class[Telerik.Sitefinity.GenericContent.Model.Content]/field[UrlName_]]
       DynamicModule.ns.Wrapped_OpenAccessMembershipProvider_4b00f6fbda094382b600901add4ec12e.Initialize(String providerName, NameValueCollection config, Type managerType) +284
       Telerik.Sitefinity.Data.ManagerBase`1.InstantiateProvider(IDataProviderSettings providerSettings, Type providerType, ExceptionPolicyName policy, ManagerBase`1 manager) +2706
       Telerik.Sitefinity.Data.ManagerBase`1.InstantiateProvider(IDataProviderSettings providerSettings, ExceptionPolicyName policy, ManagerBase`1 manager) +117
       Telerik.Sitefinity.Data.ManagerBase`1.SetProvider(String providerName, String transactionName) +407
       Telerik.Sitefinity.Data.ManagerBase`1..ctor(String providerName, String transactionName) +249
       Telerik.Sitefinity.Security.UserManager..ctor(String providerName, String transactionName) +39
    
    [TargetInvocationException: Exception has been thrown by the target of an invocation.]
       System.RuntimeMethodHandle._InvokeConstructor(IRuntimeMethodInfo method, Object[] args, SignatureStruct& signature, RuntimeType declaringType) +0
       System.RuntimeMethodHandle.InvokeConstructor(IRuntimeMethodInfo method, Object[] args, SignatureStruct signature, RuntimeType declaringType) +15
       System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +281
       System.Reflection.ConstructorInfo.Invoke(Object[] parameters) +17
       Telerik.Sitefinity.Data.ManagerBase`1.GetManager(String providerName, String transactionName) +1323
       Telerik.Sitefinity.Security.UserManager.GetManager(String providerName, String transactionName) +41
       Telerik.Sitefinity.Security.SecurityManager.LogoutImpl(String providerName, Guid userId, String userName, Credentials credentials) +73
       Telerik.Sitefinity.Security.SecurityManager.Logout(String providerName, Guid userId) +178
       Telerik.Sitefinity.Security.SecurityManager.Logout() +257
       Telerik.Sitefinity.Security.Web.UI.LogoutForm.DoLogout(String navigateUrl) +33
       Telerik.Sitefinity.Security.Web.UI.LogoutForm.SwitchUserButton_Command(Object sender, CommandEventArgs e) +32
       System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +115
       System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +169
       System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +9
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +176
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563
    


    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1
  • Hi,

    @Duneel Muthubandara

    I think I described in the module documentation that Sitefinity does not use that app.config. You should NOT specify the connection string there. Sitefinity uses only the connection strings defined in /DataConfig/ConnectionStrings.

    @Basem Emara

    Again, in the module documentation I tried to explain how a module should be configured.The app.config of your persistent should start like this

    <?xml version="1.0"?>
    <configuration>
      <configSections>
        <section name="openaccess" type="Telerik.OpenAccess.Config.ConfigSectionHandler, Telerik.OpenAccess.Config, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7ce17eeaf1d59342" requirePermission="false" />
      </configSections>
      <openaccess xmlns="http://www.telerik.com/OpenAccess">
        <references>
          <!-- Do not add any references here, as they are added dynamically by Sitefinity
          and it will be duplicated-->    
        </references>

    Notice the comment. It is extremely important NOT to include any references there. Sitefinity merges information about meta types, it's own app.config for Telerik.Sitefinity.Model.dll and all your persistent module's app.configs. Every type knows which assembly it comes from (MetaType.AssemblyName). If you hard-code any reference there, you will get the error you've just received.I believe it is the same for Duneel Muthubandara. Please, TURN OFF open access visual studio integration. In the documentation it is explained how to configure the project to build with the proper version of OpenAccess, and which features to turn off, and how to enhance the assembly.

    @Kiril Jovchev

    Site modules are initialized on the first request to sitefinity. The Bootstrapper is called, then SiteInitializer gose over the registerd modules and initializes. All modules share the same global named transaction, and therefore, if anything fails, the module won't be installed.
    Please, reastrain from committing anything in the module initialization. Doing so might render your system unusable (especially if something goes wrong with meta types). The condition to save the meta types (e.g. Tags and Categories meta fields) is that everything went smoothly. Remove the SaveChanges, as SiteInitializer, and more preciesly, its InstallContext, takes care of this.
    Failures are wrapped in try-catch so that the system is protected from going unusable if one of the modules fails installing. Therefore, you should debug the module and look for the exception that is thrown (this is the only case when install context doesn't save).

    Best wishes,
    Dido
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  • Hi Dido

    I had filed 2 tickets for the Products module, and your support guys have been really helpfull and they spoted 2 bugs:
    The install bug is next one in ProductsModule.cs:
            pageInfo.Parameters["ModuleName"] = ProductsModule.ModuleName;
            var comments = new BackendContentView() ControlDefinitionName = ProductsDefinitions.BackendCommentsDefinitionName ;
            initializer.CreatePageFromConfiguration(pageInfo, moduleNode, comments);
        
    The highlighted moduleNode should be productsNode 

    And the next bug was with that Taxonomy filters were not working
    So the bug is in Data\ProductsDataProvider.cs
    public override IEnumerable GetItemsByTaxon(Guid taxonId, bool isSingleTaxon, string propertyName, Type itemType, string filterExpression, string orderExpression, int skip, int take, ref int? totalCount)
        if (itemType == typeof(ProductItemUrlData))
        
            this.CurrentTaxonomyProperty = propertyName;
    The highlighted ProductItemUrlData should be ProductItem.

    May be you guys from Telerik should consider to put the version of the module with fixes for download, or may a sicky for a while?

    Kiril Jovchev
    Software Architect
    UOMA OY | Merimiehenkatu 36 D | FI-00150 Helsinki | www.uoma.fi



  • Thanks Dido for all your help (and Kiril :). The Products Module is all there and complete. It is just a matter of setting it all up correctly. For example, I just figured out that the App.config file has to be set as an embedded resource (http://goo.gl/AREMY).

    Kinda bumpin heads without the documents for this one though. In the latest Jan 14th SDK, the "getting start" screen says "soon" for the "Create a module with OA" documentation. That should shed light on many things.
  • Ah-hah!! The documents is in a Word doc in the Products Module project folder (it's obviously excluded from the solution view). Nice!!!
  • Hey guys,

    Since you seem to be much into this products module: how can I add some more custom fields to it?
    What would be the steps to do this?

    Thanks,
    Daniel
  • Hey Daniel,

    The way I went about figuring that out was to do a search for all instances of "whatsinthebox", one of the custom fields that Telerik added for the sample. I then duplicated and renamed all instances, that's a bit simplified but you know what I mean. One thing I've encountered is that if I add one field, install the module to see if it works and then try to add another it won't install the second time and there's no uninstall method. So be sure to do this on a test DB and backup the test db before the install and do a restore before each time you try to add any new data fields.

    Hope that helps, if not later this evening (EST) I can dig through and tell you what files were modified specifically.

    Cheers,
    Phill
  • Hi Phill,

    Thanks for the explanation.
    Well, that seems quite a lot of work for some fields :(

    For now, I'm still struggling with the bugs mentioned in this post: saving taxonomies and filtering on them. 
    Can't get them to work. 

    Maybe I'm the only one having such problems with these custom modules, but it took quite a while before I had installed this ProductsModule. And now I have the same problem with the Migration module. It just doesn't shows up in the menu. Frustrating!

    Anyway, I'll try your suggestions.

    Thanks!
    Daniel
  • Hi Daniel,

    If you want I can zip up my Products Module code and send to you. I've added some simple custom fields (ItemNumber, ModelNumber, etc) in addition to what Telerik had added. I've also added the fixes that Kiril has supplied as well. You can email me at phillh at pbnj [dot] ca  and I'll send you a zip, might help you get a jump start.

    Regards,
    Phill