How do I disable products in Kentico 10?

徘徊边缘 提交于 2019-12-12 04:27:51

问题


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 ?


回答1:


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.




回答2:


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));



来源:https://stackoverflow.com/questions/42114600/how-do-i-disable-products-in-kentico-10

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!