How do I disable products in Kentico 10?

2019-09-14 19:59发布

I am performing CRUD operations for products of e-commerce site in kentico 10.I can add and update products using below API

SKUInfoProvider.SetSKUInfo(updateProduct);

Also there is an API for deleting product

SKUInfoProvider.DeleteSKUInfo(updateProduct);

But I do not wish to delete the product from database,rather just disable them so that they do not show up to the end users and still stay in the database .

This are the SKU Objects for the product :

var sku = new SKUInfo
            {
                //SKUName = Convert.ToString(dr["SHORT_DESCRIPTION"]).Trim('"') + " (" + Convert.ToString(dr["MANUFACTURER_PART_NUMBER"]) + ")",
                SKUName = Convert.ToString(dr["MANUFACTURER_PART_NUMBER"]),
                SKUDescription = Convert.ToString(dr["TECHNICAL_SPECIFICATIONS"]).Trim('"'),
                SKUShortDescription = Convert.ToString(dr["SHORT_DESCRIPTION"]).Trim('"'),
                SKUPrice = ValidationHelper.GetDouble(dr["RESELLER_BUY_INC"], 0),
                SKURetailPrice = ValidationHelper.GetDouble(dr["RRP_INC"], 0),
                SKUEnabled = true,
                SKUSiteID = siteId,
                SKUProductType = SKUProductTypeEnum.Product,
                SKUManufacturerID = manufacturer.ManufacturerID,
                SKUDepartmentID = department.DepartmentID,
                SKUHeight = 100,
                SKUWidth = 100,
                SKUAvailableItems = 1,
                SKUSellOnlyAvailable = true
            };

I tried to set SKUEnabled as false but still user can see the product.So, is there any property to disable products ?

标签: kentico
2条回答
神经病院院长
2楼-- · 2019-09-14 20:29

How are you displaying the Sku? If it's a repeater, you may need to filter by the "SKUEnabled = 1" in your where condition.

Another option is if the Product has a Page (it's not a stand alone sku) you can unpublish the page itself.

查看更多
We Are One
3楼-- · 2019-09-14 20:30

Well... A user doesn't see products per say - he sees pages that are connected to your SKUs/products. When you disable the SKU - the page is still visible, but (if I am not mistaken) "Add To Cart" is not shown. You need to unpublish product pages. You need to set DocumentPublishTo of the document to some date before for ex:

ProductNode.SetValue("DocumentPublishTo", DateTime.Now.AddDays(-1));

查看更多
登录 后发表回答