コード例 #1
0
        public FacebookShopRequestContainer RemoveProduct(ContentItem product)
        {
            var productPart  = product.As <ProductPart>();
            var facebookPart = product.As <FacebookShopProductPart>();

            try {
                if (productPart != null && facebookPart != null && facebookPart.SynchronizeFacebookShop)
                {
                    // I need to assign RetailerId parameter to my context.
                    var context = new FacebookShopProductDeleteRequest()
                    {
                        Method     = FacebookShopProductDeleteRequest.METHOD,
                        Valid      = true,
                        RetailerId = productPart.Sku
                    };

                    return(RemoveProduct(context));
                }
            } catch (Exception ex) {
                // I need to tell it was impossible to synchronize the product on Facebook Shop.
                if (productPart != null)
                {
                    Logger.Debug(ex, T("Product {0} can't be removed from Facebook catalog.", productPart.Sku).Text);
                }
                else
                {
                    Logger.Debug(ex, T("Product part or Facebook part are not valid.").Text);
                }
                return(null);
            }

            return(null);
        }
コード例 #2
0
        public FacebookShopRequestContainer RemoveProduct(FacebookShopProductDeleteRequest context)
        {
            FacebookShopRequestContainer requestContainer = new FacebookShopRequestContainer();

            requestContainer.Requests.Add(context);

            // Facebook Shop Site Settings: I need url, catalog id and access token.
            _fsssp = _workContext.GetContext().CurrentSite.As <FacebookShopSiteSettingsPart>();
            FacebookShopServiceContext ctx = new FacebookShopServiceContext()
            {
                ApiBaseUrl  = _fsssp.ApiBaseUrl,
                BusinessId  = _fsssp.BusinessId,
                CatalogId   = _fsssp.CatalogId,
                AccessToken = _fsssp.AccessToken
            };

            FacebookShopProductBatch(requestContainer);

            return(requestContainer);
        }