Esempio n. 1
0
        public void ImportNewShopifyProduct(ShopifyNewProductImportContext context)
        {
            var monitor = _monitoringService.ProvisionMonitor(BackgroundJobType.ImportNewShopifyProduct);

            var hangfireJobId = BackgroundJob.Enqueue <JobRunner>(
                x => x.ImportNewShopifyProduct(_tenantContext.InstanceId, context, monitor.Id));

            _monitoringService.AssignHangfireJob(monitor.Id, hangfireJobId);
        }
Esempio n. 2
0
        public void RunNewProduct(ShopifyNewProductImportContext context)
        {
            if (MonsterConfig.Settings.DisableShopifyPut)
            {
                _logService.Log(LogBuilder.ShopifyPutDisabled());
                return;
            }

            var newVariants = CleanAndBuildVariantPayload(context.AcumaticaItemIds);

            var product = new ProductNew()
            {
                title        = context.ProductTitle,
                vendor       = context.ProductVendor,
                product_type = context.ProductType,
                variants     = new List <ShopifyVariantNew>()
            };
            var parent = new { product = product };

            product.variants = newVariants;

            // POST new Product via Shopify API
            //
            var result           = _productApi.CreateProduct(parent.SerializeToJson());
            var resultProduct    = result.DeserializeFromJson <ProductParent>();
            var shopifyProductId = resultProduct.product.id;

            // Run ShopifyInventoryGet to pull into local cache
            //
            _shopifyInventoryGet.Run(shopifyProductId);
            var productRecord = _syncInventoryRepository.RetrieveProduct(shopifyProductId);

            // Execution Log entry
            //
            var log = LogBuilder.CreatedShopifyProduct(productRecord);

            _logService.Log(log);

            // Create Sync Records for the Variants that were created
            //
            foreach (var newVariant in newVariants)
            {
                var variantRecord = productRecord.ShopifyVariants.FirstOrDefault(x => x.ShopifySku == newVariant.sku);
                CreateSyncRecord(newVariant.sku, variantRecord);
            }

            // Update Inventory data
            //
            foreach (var itemId in context.AcumaticaItemIds)
            {
                RunInventoryUpdate(itemId);
            }
        }
Esempio n. 3
0
        public ActionResult RunImportToCreateNewProduct(
            List <string> acumaticaItemIds, string title, string productType, string vendor)
        {
            var context = new ShopifyNewProductImportContext();

            context.ProductTitle     = title;
            context.ProductVendor    = vendor;
            context.ProductType      = productType;
            context.AcumaticaItemIds = acumaticaItemIds;
            _oneTimeJobService.ImportNewShopifyProduct(context);

            return(JsonNetResult.Success());
        }
Esempio n. 4
0
        public void ImportNewShopifyProduct(ShopifyNewProductImportContext context)
        {
            if (!TestIsShopifyPutEnabled())
            {
                return;
            }

            Action action = () =>
            {
                RefreshInventory();
                var state = _stateRepository.RetrieveSystemStateNoTracking();
                if (state.InventoryRefreshState != StateCode.Ok)
                {
                    _executionLogService.Log("Inventory Refresh is broken; aborting ImportNewShopifyProduct");
                    return;
                }

                _syncManager.ImportNewShopifyProduct(context);
            };

            Run(action);
        }
Esempio n. 5
0
 public void ImportNewShopifyProduct(
     Guid instanceId, ShopifyNewProductImportContext context, long jobMonitorId)
 {
     ExecuteJob(instanceId, () => _processDirector.ImportNewShopifyProduct(context), jobMonitorId);
 }
Esempio n. 6
0
 public void ImportNewShopifyProduct(ShopifyNewProductImportContext context)
 {
     _shopifyProductVariantPut.RunNewProduct(context);
 }