Marking a Category UnPublished, mark the Products UnPublished

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
7 years ago
Any way that when you mark the Category UnPublished that all the items in that Category are marked UnPublished? If not, can I add this as a suggestion? Pleeeeeease?
7 years ago
Quickest way would be to manage product, search for product within the category, select the items & export selected items to excel.  In Excel sheet, find the column labeled "Publish", change top cell to False, drag False value to bottom of sheet, re-import sheet back into Nop.
7 years ago
you can bulk edit the product and delete them.
7 years ago
dootchie wrote:
Any way that when you mark the Category UnPublished that all the items in that Category are marked UnPublished? If not, can I add this as a suggestion? Pleeeeeease?


You could do something like:

var prevPublished = category.Published;

...

if (prevPublished != category.Published)
{
    var products = _productService.SearchProducts(categoryIds: new List<int> {category.Id}, showHidden: true);
    foreach (var product in products)
    {
        product.Published = category.Published;
        _productService.UpdateProduct(product);
    }
}

In the Edit method of the CategoryController (Nop.Admin).
But pay attention that one product can be assigned to more than one category.
7 years ago
Thanks. Good suggestion and good reminder!!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.