Thursday, November 21, 2019 3:48:22 AM
  • Posted: Thursday, September 12, 2019 8:56 AM
  • 4
Hi,

I'm wondering if it's possible to add custom models/components into the platform without the use of plugins?

For example, I want to create a featured vendor component which can be hardcoded through JSON/Model in the component file.

Is what I want to achieve possible without creating a plugin and if so, is there any information on custom components as I can't find this in the docs?

Thanks
0
  • Posted: Thursday, September 12, 2019 10:00 AM
  • Moderator
  • 368
Hi,

First of all, thanks for the post. GrandNode is pluginable software, it's better to extend its functionality by plugins. To be honest it's also the easiest way to implement changes in it. Is there any reason, why you prefer to do it in source code, instead of plugin creation? GrandNode developer documentation covers topic of plugin creation, because it's the recommended one. I don't know your exact requirements, so I'm not sure on which plugin example you should focus.

0
  • Posted: Thursday, September 12, 2019 3:42 PM
  • 4
Thanks for replying, I've had a quick look at the plugins section on the documentation and tried to implement that but every time I try to reload the list of plugins it crashes out without catching the exception. (System.Threading.Tasks.TaskCanceledException: A task was canceled). Wondering if you've got any ideas on this?

The reason I was looking into not doing it as a plugin originally was just because the component didn't really require much logic/I was unsure of the overhead on the plugins compared to a few class files in the source code.

Thanks
0
  • Posted: Friday, September 13, 2019 7:04 AM
  • Moderator
  • 368
I'm not able to tell you what's wrong, because without code it's hard to find the issue. If you want, please post the part of code, maybe we will be able to help you somehow.
0
  • Posted: Friday, September 13, 2019 8:05 AM
  • 4
The code I've added to try this has just been the same as the base plugin creation guide - http://docs.grandnode.com/how-to-create-base-plugin-3

The only difference I can see is that I've tried changing the project references/property groups for the plugin - tried with ..\ and ..\{Top folder}
e.g.
<ProjectReference Include="..\PluginTestProj\Grand.Services\Grand.Services.csproj">
      <Private>false</Private>
</ProjectReference>

FeaturedVendorsPlugin.cs

using Grand.Core.Plugins;
using Grand.Services.Common;
using System.Threading.Tasks;

namespace Grand.Plugin.Misc.FeaturedVendors
{
    public class FeaturedVendorsPlugin : BasePlugin, IMiscPlugin
    {
        #region Methods
        public override async Task Install()
        {
            await base.Install();
        }
        public override async Task Uninstall()
        {
            await base.Uninstall();
        }

        #endregion
    }
}


DependencyRegistrar.cs

using Autofac;
using Grand.Core.Configuration;
using Grand.Core.Infrastructure;
using Grand.Core.Infrastructure.DependencyManagement;

namespace Grand.Plugin.Misc.FeaturedVendors
{
    public class DependencyRegistrar : IDependencyRegistrar
    {
        public void Register(ContainerBuilder builder, ITypeFinder typeFinder, GrandConfig config)
        {
            builder.RegisterType<FeaturedVendorsPlugin>().InstancePerLifetimeScope();
        }

        public int Order
        {
            get { return 1; }
        }
    }
}
0
  • Posted: Friday, September 13, 2019 1:12 PM
  • 4
Update on this - Turns out the issue was the description hadn't been changed to copy if newer and as such wasn't copied into the project references, apologies.
0