Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • stephen 83 posts 124 karma points
    Nov 24, 2016 @ 16:53
    stephen
    0

    Stock Management

    Having replicated a site originally on a physical server to azure, I am unable to enter a value using the datatype Tea Commerce Stock Management whereas I can implement this successfully in the original back office.

    In my original site the node id is inserted as the SKU along with the stock value (in the table TeaCommerce_Stock) but this does not occur in the azure-based site/db.

    The Tea Commerce version is 3.0.7 The Umbraco is 7.3.4

  • Anders Burla 2560 posts 8256 karma points
    Nov 24, 2016 @ 19:20
    Anders Burla
    0

    I stephen

    Tried to set a specific SKU for a product to see if that will then be saved. Never experienced this before. Anything in the log files?

    Kind regards

    Anders

  • stephen 83 posts 124 karma points
    Nov 25, 2016 @ 09:39
    stephen
    0

    Hi No error in log file but it indicates the relevant ID has been published but the Umbraco.config file has not been updated.

     <ShopProductAttributes id="2366" key="6c91eed3-0305-45ef-9550-d840db19e119" parentID="2354" level="7" creatorID="1" sortOrder="0" createDate="2016-11-24T11:05:06" updateDate="2016-11-25T09:28:50" nodeName="XXL" urlName="xxl" path="-1,2214,2215,2342,2348,2353,2354,2366" isDoc="" nodeType="2219" creatorName="admin" writerName="admin" writerID="1" template="0" nodeTypeAlias="ShopProductAttributes">
                <hideInSitemap>0</hideInSitemap>
                <umbracoNaviHide>0</umbracoNaviHide>
                <pageTitle><![CDATA[XXL]]></pageTitle>
                <doNotUseSizeAndColour>0</doNotUseSizeAndColour>
                <sizes><![CDATA[2358]]></sizes>
                <colour><![CDATA[2362]]></colour>
              </ShopProductAttributes>
    

    I noticed the field "stock" is not retained in the xml.

    I manually entered a value in the stock table but that makes no difference.

    enter image description here

    Finally, I did a check in the database and the tables cmsPropertyType, cmsPropertyTypeGroup and cmsContentType all match between the working version on the physical server and the non working version on azure.

    Furthermore, just did a test to capture the event when Publishing and although it captures the property it does NOT capture the value (it captures the id and the name)

    Finally, changing the datatype to a textfield saves the value which is also captured in the event handler therefore it looks like a bug in the teacommerce: stock management data type.

  • stephen 83 posts 124 karma points
    Nov 25, 2016 @ 12:52
    stephen
    0

    The plugin retrieves the sku value from the following

    jQuery('#sku').val()
    

    but I cannot find where this is set.

    Also if I hard code in a node id the event handler captures the id and the value.

    I do not think the angular stock management controller is capturing either the #sku or backoffice/teacommerce/products/poststock?pageid

    Error 500 is displayed when the Property Editor is called: http://[name].azurewebsites.net/umbraco/backoffice/teacommerce/products/getstock/?pageId=2366 500 (Internal Server Error)

  • Anders Burla 2560 posts 8256 karma points
    Nov 28, 2016 @ 09:15
    Anders Burla
    0

    The stock is not saved in the DB as a property value - it is only saved in the special Tea Commerce stock DB table. So that is not a bug - that is by purpose.

    You can download the Tea Commerce code for Umbraco here. Maybe you can debug and see what error is thrown. Is pretty weird that it works in one environment, and then you move it and then ti doesnt work anymore :)

    https://github.com/TeaCommerce/Tea-Commerce-for-Umbraco

    Kind regards

    Anders

  • stephen 83 posts 124 karma points
    Dec 02, 2016 @ 16:44
    stephen
    0

    enter image description here

    cannot find path to nor

    backoffice/teacommerce/products/poststock?productIdentifier=
    

    which is called in the stock-management.controller.js

  • Anders Burla 2560 posts 8256 karma points
    Dec 06, 2016 @ 13:20
    Anders Burla
    0

    And all dll files, javascript files etc have been copied to the Azure site? It did work on the other setup you had - right?

    Kind regards

    Anders

  • stephen 83 posts 124 karma points
    Dec 08, 2016 @ 12:28
    stephen
    0

    Hopefully this may be of assistance to others.

    1. Get Error 404 for "backoffice/teacommerce/products/getstock"

    enter image description here

    (NOTE: one of the constant bugbears of angular is caching. Whether "getstock" or "GetStock" makes any difference I have changed the path and still it displays the same. Event setting web.config to debug. Event using Tools to clear cached and hard reload. It quite often makes no difference. Having to rename files is a joke. So much for progress in programming)

    1. Create my own control part replicating the teacomm process

    enter image description here

    Error thrown when referencing IXmlNodeProductInformationExtractor

    Discovered the current version does not include it.

    enter image description here

    So created my own process to Get/Post Stock Value

    by creating a Controller in App_Code (NewStockApiController.cs) and a new model (called StockModel.cs)

    which works.

    NewStockApiController (in App_Code)

     [Umbraco.Web.Mvc.PluginController("TPS")]
    public class NewStockApiController : UmbracoAuthorizedJsonController
    {....
    
    public TeaCommerce.Umbraco.Application.Controllers.ProductsController.Stock GetStock(string pageId)
        {
            TeaCommerce.Umbraco.Application.Controllers.ProductsController.Stock stock1 = new TeaCommerce.Umbraco.Application.Controllers.ProductsController.Stock();
            stock1.Sku = "";
            stock1.Value = "";
            try
            {
                YOUR NAMESPACE.Models.StockModel.dbContextShopper stockProperties = new YOUR NAMESPACE.Models.StockModel.dbContextShopper();
                var results = stockProperties.Database.SqlQuery<YOURNAMESPACE.Models.StockModel.stockProps>("Select * from [" + dbToUse + "].[dbo].[TeaCommerce_Stock] where StoreID = " + StoreId + " and SKU = '" + pageId + "'");
                foreach (var item in results)
                {
                    string[] splitStock = item.stock.ToString().Split('.');
                    string stockValToUse = splitStock[0];
                    stock1.Sku = item.SKU.ToString();
                    stock1.Value = stockValToUse;
                }
            }
            catch (Exception dbEr){ }            
            return stock1;
        }
    
        public string PostStock(string pageId, TeaCommerce.Umbraco.Application.Controllers.ProductsController.Stock stock)
        {
            string val = "";
            long storeId = 1;
            decimal stockVal = Decimal.Parse(stock.Value);
            ProductService.Instance.SetStock(1, pageId, stockVal);
            return val;
        }
    

    The angular controller path references:

    $http.get('backoffice/TPS/NewStockApi/GetStock?pageId=' + $routeParams.id + variantId).success(function (data) {
    

    and

    $http.post('backoffice/TPS/NewStockApi/PostStock?pageId=' + $routeParams.id + variantId, data);
    

    The Manifest:

     {
    
    
     propertyEditors: [{
    alias: 'My.StockManagement',
      name: 'New Stock Plugin V[Number][Letter]',
      editor: {
        view: '~/App_Plugins/stock/stock-management.html',
        hideLabel: false,
        valueType: 'STRING'
      }
      }],
      javascript: [
      '~/App_Plugins/stock/stock-management.controller.js'
    
    
     ]
    

    }

    The StockModel:

     [Table("TeaCommerce_Stock")]
        public class stockProps
        {
            [Key]
            public virtual long storeID { get; set; }
            public virtual string SKU { get; set; }
            public virtual Decimal stock { get; set; }
    
        }
    
        public class dbContextShopper : DbContext
        {
            public dbContextShopper() : base("dbContextShopper") { }
            public DbSet<stockProps> Stock { get; set; }
        }
    

    Originally I thought this had some connection between platforms (physical server and azure) but it is inconsistencies in versions and when paying licence fees I think it is a bit galling to be expected to root out problems and fix them. That is something I would expect Tea Commerce staff/developers to fulfil.

    Anyway this may be of use to others.

  • Anders Burla 2560 posts 8256 karma points
    Dec 08, 2016 @ 21:01
    Anders Burla
    0

    Hi Stephen

    Sse that you solved your issue. What I would like to know is what is different from your local setup that worked and the Azure?

    Just downloaded the starter kit running latest Umbraco and Tea Commerce and the products have a stock management data type - and all is working. So just wondering what might be different in your case since you got the 404 error.

    Use the "dev" branch as that is latest

    https://github.com/TeaCommerce/Starter-kit-for-Umbraco

    Kind regards

    Anders

Please Sign in or register to post replies

Write your reply to:

Draft