Inhalte aufrufen

Profilbild

adding new properties to ProductSearchContext from plugin

SmartStore Plugin Development Plugin Development Plugins Plugin Developmen

  • Bitte melden Sie sich an, um eine Antwort zu verfassen.
39 Antworten zu diesem Thema

#21 Sherif Ahmed

Sherif Ahmed

    Advanced Member

  • Members
  • PunktPunktPunkt
  • 35 Beiträge

Geschrieben: 24 April 2014 - 15:52

I found also you are ignoring any custom view engine ... :(


Sherif Ahmed

Software Engineer

Egypt


#22 Murat Cakir

Murat Cakir

    SmartStore AG

  • Administrators
  • 1118 Beiträge

Geschrieben: 24 April 2014 - 22:23

Hi Sherif,

 

I'm going to make a small fix for version 2.0.2, which enables you to register your custom view engine like you did, or from an IStartupTask. Sorry for that.


Murat Cakir
SmartStore AG


#23 Murat Cakir

Murat Cakir

    SmartStore AG

  • Administrators
  • 1118 Beiträge

Geschrieben: 24 April 2014 - 22:30

Please see following commit: 3d96991a5c30


Murat Cakir
SmartStore AG


#24 Sherif Ahmed

Sherif Ahmed

    Advanced Member

  • Members
  • PunktPunktPunkt
  • 35 Beiträge

Geschrieben: 25 April 2014 - 00:56

Thanks Murat ... Appreciated my dear


Sherif Ahmed

Software Engineer

Egypt


#25 Sherif Ahmed

Sherif Ahmed

    Advanced Member

  • Members
  • PunktPunktPunkt
  • 35 Beiträge

Geschrieben: 26 April 2014 - 00:51

just a question ...

 

is it better to use the IDataSeeder <MyObjectContext> to seed the plugin or in the plugin Install method

 

I can do it right that 

var migrator = new DbMigrator (new Configuration ());
migrator.Update ("Initial");

and after that I can seed my plugin using my services instead of using the context.

 

which is better and Which is the right ... from your point of view?


Sherif Ahmed

Software Engineer

Egypt


#26 Murat Cakir

Murat Cakir

    SmartStore AG

  • Administrators
  • 1118 Beiträge

Geschrieben: 27 April 2014 - 01:46

Always use the data seeder, it's the easiest approach. It should not be necessary to call DbMigrator's Update method, This is done automatically when you register a MigrateDatabaseInitializer instance in the static constructor of your context class. Please have a look at the plugin Shipping.ByTotal for best practice patterns.


Murat Cakir
SmartStore AG


#27 Sherif Ahmed

Sherif Ahmed

    Advanced Member

  • Members
  • PunktPunktPunkt
  • 35 Beiträge

Geschrieben: 28 April 2014 - 09:15

Hello again,

 

my context is not saving changes When 

_context.SaveChanges ();

in EfRepository

 

the context is working fine for inserting but not for updating ... 

 

here is the controller Delete Action

PluginController.cs

[HttpPost]
public ActionResult Delete(int id)
{
       if (!_commonServices.Permissions.Authorize(MyPluginPermissionProvider.ManageMyPlugin))
           return AccessDeniedPartialView();

       var entity = _pluginService.GetEntityById(id);
       if (entity == null)
           return RedirectToAction("List");

       _pluginService.DeleteEntity(entity);

       / / Activity log
       _commonServices.CustomerActivity.InsertActivity("DeleteEntity", T("Plugins.Something.Something.ActivityLog.DeleteEntity"), entity.Name);

       NotifySuccess(T("Plugins.Something.Something.Deleted"));
       return RedirectToAction("List");
}

and here is the plugin service.cs

PluginService.cs

public virtual Entity GetEntityById(int entityId)
{
        if (entityId == 0)
            return null;

        return _entityRepository.GetById(entityId);
}
public virtual void DeleteEntity(Entity entity)
{
       if (entity == null)
            throw new ArgumentNullException("entity");

       entity.Deleted = true;
       UpdateEntity(entity);
}
public virtual void UpdateEntity(Entity entity)
{
       if (entity == null)
            throw new ArgumentNullException("entity");

       _entityRepository.Update(entity); / / HERE IS NOT UPDATING THE ENTITY

       / / Event notification
       _commonServices.EventPublisher.EntityUpdated(entity);
}

Sherif Ahmed

Software Engineer

Egypt


#28 Murat Cakir

Murat Cakir

    SmartStore AG

  • Administrators
  • 1118 Beiträge

Geschrieben: 29 April 2014 - 00:26

When the update does not occur on SaveChanges(), then following causes are the most probable:

  • Repository.AutoCommitEnabled is false.
  • DbContext.Configuration.AutoDetectChangesEnabled is false.

If, for example, the latter is false, EF cannot detect the change on the Deleted property, therefore SaveChanges() never gets called. You could, however, call SaveChanges() explicitly. But best approach would be to ensure that AutoDetect is turned on in shortliving unit of works (like a web request), and only turned off in rather longliving ones.


Murat Cakir
SmartStore AG


#29 Sherif Ahmed

Sherif Ahmed

    Advanced Member

  • Members
  • PunktPunktPunkt
  • 35 Beiträge

Geschrieben: 29 April 2014 - 09:05

I checked that and found AutoCommiteEnabled is true and AutoDetectChangesEnbaled is also true,

however the context is not saving the changes ... 

 

I don't know why?

 

but I just changed instead of using the ICommonService .... to use each service individually and it works fine ..

I did not tracked why it's not working but the problem is coming from cache ...

so I just want to notify you with that .... if it's known issue or not or may be I'm miss using it


Sherif Ahmed

Software Engineer

Egypt


#30 Sherif Ahmed

Sherif Ahmed

    Advanced Member

  • Members
  • PunktPunktPunkt
  • 35 Beiträge

Geschrieben: 29 April 2014 - 20:00

After tracing the issue .. I found that in the my DependencyRegistrar.cs

 

I wrote the service type registration as 

builder.RegisterType<PluginService>().As<IPluginService>().WithRequestCache().InstancePerHttpRequest();

and the ICommonService it is using static cache ... so I think this is the problem.


Sherif Ahmed

Software Engineer

Egypt


#31 Sherif Ahmed

Sherif Ahmed

    Advanced Member

  • Members
  • PunktPunktPunkt
  • 35 Beiträge

Geschrieben: 01 May 2014 - 00:01

I was able to override the admin route (or not actually override I just put my plugin admin route before the default admin route) ,

but I facing one problem which is ... in admin layout the Navbar.cshtml => navbar-tools div

 

the problem is when the plugin render a page for editing all the menus works fine except the ClearCache, account and the about smartstore.net links which all are in the nav-bar tools div.

and after tracing I found that (for example) the ClearCache anchor is written like that

<a href="@Url.Action("ClearCache", "Common", new { previousUrl = Request.RawUrl })">
    <i class="icon-remove"></i>
    @T("Admin.Header.ClearCache")
</a>

so my question is that should I change the action to be as below ( I also check if it will affect the normal behavior and I found that it will not affect it )

@Url.Action("ClearCache", "Common", new { previousUrl = Request.RawUrl, area = "Admin" })

for the purpose of the plugins or what should I do?


Sherif Ahmed

Software Engineer

Egypt


#32 Sherif Ahmed

Sherif Ahmed

    Advanced Member

  • Members
  • PunktPunktPunkt
  • 35 Beiträge

Geschrieben: 04 May 2014 - 11:13

how to implement IConsumer<TabStripCreated> event for a product-edit page.... I just want to inject my tab in the product edit page

 

I was able to implement, but i can not inject my content from an action using ajax or even without ajax


Sherif Ahmed

Software Engineer

Egypt


#33 Murat Cakir

Murat Cakir

    SmartStore AG

  • Administrators
  • 1118 Beiträge

Geschrieben: 05 May 2014 - 17:08

I was able to override the admin route (or not actually override I just put my plugin admin route before the default admin route) ,

but I facing one problem which is ... in admin layout the Navbar.cshtml => navbar-tools div

 

the problem is when the plugin render a page for editing all the menus works fine except the ClearCache, account and the about smartstore.net links which all are in the nav-bar tools div.

and after tracing I found that (for example) the ClearCache anchor is written like that

<a href="@Url.Action("ClearCache", "Common", new { previousUrl = Request.RawUrl })">
    <i class="icon-remove"></i>
    @T("Admin.Header.ClearCache")
</a>

so my question is that should I change the action to be as below ( I also check if it will affect the normal behavior and I found that it will not affect it )

@Url.Action("ClearCache", "Common", new { previousUrl = Request.RawUrl, area = "Admin" })

for the purpose of the plugins or what should I do?

 

That should do the trick. But I fixed this already for V2.0.2 which get released tomorrow hopefully.


  • Sherif Ahmed gefällt das

Murat Cakir
SmartStore AG


#34 Murat Cakir

Murat Cakir

    SmartStore AG

  • Administrators
  • 1118 Beiträge

Geschrieben: 05 May 2014 - 17:36

how to implement IConsumer<TabStripCreated> event for a product-edit page.... I just want to inject my tab in the product edit page

 

I was able to implement, but i can not inject my content from an action using ajax or even without ajax

    public class MyTabConsumer : IConsumer<TabStripCreated>
    {
        public void HandleEvent(TabStripCreated eventMessage)
        {
            switch (eventMessage.TabStripName.ToLower())
            {
                // Hook the 'product-edit' Tab. You can see the tab names in the corresponding root views (where the event gets fired)
                case "product-edit":
                    // Parse your partial view. Full virtual path must be supplied, otherwise path resolving will not succeed.
                    // The second param is the model which gets passed over from the root view. We just pass it through to our partial.
                    var content = eventMessage.Html.Partial("~/Plugins/MyPlugin/Views/Controller/_MyPartial.cshtml", eventMessage.Model);
                    // Create the tab and pass the partial result as it's content
                    var tab = eventMessage.ItemFactory.Add().Text("My Tab").Content(content.ToString());
                    break;
            }
           
        }
    }

Now here comes the trickier part: performing a custom action when the user saves, updates or deletes the product entity (user clicked on one of the action buttons at the top of the product create/edit page). In this case you surely want to update your plugin specific data as well. You'll need a client-side (JavaScript) event subscriber for this:

EventBroker.subscribe("entity-commit", function (msg, data) {
           console.log(data.action); // 'insert' | 'update' | 'delete'
           console.log(data.type); // Type of entity (at the moment only 'product' is supported)
           console.log(data.id); // ID of entity
});

  • Sherif Ahmed und SalehBagheri gefällt das

Murat Cakir
SmartStore AG


#35 Sherif Ahmed

Sherif Ahmed

    Advanced Member

  • Members
  • PunktPunktPunkt
  • 35 Beiträge

Geschrieben: 07 May 2014 - 12:47

Hello again :)

 

I just asking is there a way to center a window created in the page when I set the width and height the window grows to the left of the screen like that

Html.SmartStore().Window()
    .Name("Name")
    .Title("")
    .Content("")
    .FooterContent("")
    .Modal(true)
    .Height(1000)
    .Width(500)
    .Visible(false)
    .Render();

Thanks in advance


Sherif Ahmed

Software Engineer

Egypt


#36 Murat Cakir

Murat Cakir

    SmartStore AG

  • Administrators
  • 1118 Beiträge

Geschrieben: 07 May 2014 - 15:54

Hello again :)

 

I just asking is there a way to center a window created in the page when I set the width and height the window grows to the left of the screen like that

Html.SmartStore().Window()
    .Name("Name")
    .Title("")
    .Content("")
    .FooterContent("")
    .Modal(true)
    .Height(1000)
    .Width(500)
    .Visible(false)
    .Render();

Thanks in advance

 

You're right, doesn't work. Fixed this: ad646a3e4469.


  • Sherif Ahmed gefällt das

Murat Cakir
SmartStore AG


#37 Sherif Ahmed

Sherif Ahmed

    Advanced Member

  • Members
  • PunktPunktPunkt
  • 35 Beiträge

Geschrieben: 07 May 2014 - 22:04

Thank you Dear


Sherif Ahmed

Software Engineer

Egypt


#38 Sherif Ahmed

Sherif Ahmed

    Advanced Member

  • Members
  • PunktPunktPunkt
  • 35 Beiträge

Geschrieben: 07 May 2014 - 23:17

Is there a way to upload more than one picture while adding pictures for products?


  • MediArt gefällt das

Sherif Ahmed

Software Engineer

Egypt


#39 Murat Cakir

Murat Cakir

    SmartStore AG

  • Administrators
  • 1118 Beiträge

Geschrieben: 08 May 2014 - 15:29

Is there a way to upload more than one picture while adding pictures for products?

 

No, not at the moment.


  • Sherif Ahmed gefällt das

Murat Cakir
SmartStore AG


#40 Ahmed Alkhatib

Ahmed Alkhatib

    Newbie

  • Members
  • Punkt
  • 1 Beiträge

Geschrieben: 19 January 2019 - 08:58

 

Sounds complicate to me. Some suggestions to try out...

Example for a plugin razor view (embedded ressource) without any layout:
New view in /Views/MyPlugin/Tester.cshtml

@{
	Layout = "";
}

<div>Tester!</div>

New action method:

public ActionResult Tester()
{
	return View("SmartStore.Plugin.Misc.MyPlugin.Views.MyPlugin.Tester");
}

Request through: any-shop.com/Plugins/MyPlugin/Tester

Now using a light backend layout version:

@{
	Layout = "~/Administration/Views/Shared/_AdminLayout.cshtml";
}

@section navbar
{
}

<div class="section-header">
    <div class="title">
        <i class="icon icon-fire"></i>
        Hello world!
    </div>
    <div class="options">
    </div>
</div>

<div>Tester!</div>

All that you need to do is to decorate your action result with [AdminThemed] FilterAttribute




Auch markiert mit einem oder mehrerer dieser Schlüsselwörter: SmartStore Plugin Development, Plugin Development, Plugins, Plugin Developmen