Inhalte aufrufen

Profilbild

How to only load published products in admin list


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

#1 d0ndela

d0ndela

    Newbie

  • Members
  • Punkt
  • 8 Beiträge

Geschrieben: 27 July 2014 - 16:41

I have modified the Delete button function in the admin product page, we don't want the product to "disappear", we like to keep the URL active so all google visitors can still enter the shop and not end up on the frontpage (as they do if it's really deleted in the DB).

 

I am going to use the published DB value to control this as we would never use that functionality anyway.

 

So my question is, can I in some easy way modify the Administration/Views/Product/List.cshtml to only load products that are published?

 



#2 Marcus Gesing

Marcus Gesing

    SmartStore AG

  • Administrators
  • 3801 Beiträge

Geschrieben: 28 July 2014 - 10:19

If you use full text search (see general settings) you have to update the stored procedure ProductLoadAllPaged.
 
If you do not use full text search then you have to
- add public bool? Published { get; set; } to Services.Catalog.ProductSearchContext
- add if (ctx.Published.HasValue) { query = query.Where(p => p.Published == ctx.Published.Value); } to Services.Catalog.ProductService.PrepareProductSearchQuery
- extend the list filtering by updating Admin.Controllers.ProductController.ProductList, Admin.Models.Catalog.ProductListModel and Views\Product\List.cshtml
 
PS: Primary entities like products are never physically deleted, they are just marked as deleted.

Marcus Gesing

Smartstore AG


#3 d0ndela

d0ndela

    Newbie

  • Members
  • Punkt
  • 8 Beiträge

Geschrieben: 28 July 2014 - 10:25

Hi Marcus

 

Thank you for that.

I debugged into the code yesterday and it does load the stored procedure so I will try and take a look in there.

 

I did see that they are never really deleted, however when a product is marked as deleted (in the standard code) it cannot be loaded with its URL any more, that just re-directs to the front page. We don't want it to do that.


  • MediArt gefällt das

#4 Marcus Gesing

Marcus Gesing

    SmartStore AG

  • Administrators
  • 3801 Beiträge

Geschrieben: 28 July 2014 - 16:51

What about the availability period to make the product simply not available anymore?


Marcus Gesing

Smartstore AG


#5 d0ndela

d0ndela

    Newbie

  • Members
  • Punkt
  • 8 Beiträge

Geschrieben: 29 July 2014 - 03:33

I'll have a look at that functionality and see if that does what we need. Thank you :)