Copied to clipboard

Flag this post as spam?

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


  • Mite Tashev 11 posts 81 karma points
    Jun 09, 2016 @ 16:53
    Mite Tashev
    0

    Merchello stopped working when db moved to Azure

    Yesterday I moved my database to Azure and I started having problems with Merchello.

    Previously when my database was on a different host or locally everything was running fine. But when I migrated my database to Azure I get an error. Merchello error

    Also, when I go in the admin section of Merchello, it is throwing errors, it can't read the Merchello version, the content tree, etc.

    It seems like Merchello can't access the Azure database anymore, but everything else in the Umbraco Backoffice works. I can create documents, users, make updates etc.

    Merchello Version 1.14.2 Umbraco version 7.4.0

    I did a schema and data compare of the two databases, the azure and the local one, and they are identical.

    Is there some setting I need to set when moving to Azure to make Merchello work again?

  • Rusty Swayne 1655 posts 4993 karma points c-trib
    Jun 09, 2016 @ 17:27
    Rusty Swayne
    1

    The "merchCustomer" is a table name - is it present in the Azure Database? When you ported the database, is the new owner of the database tables the same as the Umbraco tables (like dbo)?

    There should not be any special steps to get Merchello to work. We're using the same connection string as Umbraco, so same auth credentials. I've personally moved it quite a few times without issue.

    It also works in the UaaS environments (also SqlAzure). If your schema's match, my guess is there is a permissions issue on some (or all) of the Merchello tables.

  • Mite Tashev 11 posts 81 karma points
    Jun 10, 2016 @ 15:46
    Mite Tashev
    0

    Thanks Rusty. Your answer helped me fix it.

    The problem was this:

    I first created the db locally, then uploaded it on my dev server. Over there I installed Merchello and the new tables that were created were created under a different schema, not the dbo schema. That was all good and working at that host, but when I switched to Azure it didn't like that my Umbraco tables were under the dbo schema and my Merchello tables were under a different schema. I had to change the schema of the Merchello tables to be dbo and that fixed it.

  • Rusty Swayne 1655 posts 4993 karma points c-trib
    Jun 10, 2016 @ 15:59
    Rusty Swayne
    0

    Thanks for replying with your fix. I've done that before myself and have got myself in the habit of always setting my local db user to dbo - some DBAs hate this =).

  • Mite Tashev 11 posts 81 karma points
    Jun 14, 2016 @ 16:06
    Mite Tashev
    0

    Hey Rusty

    It turned out it's not quite fixed yet. I'm able to use the Merchello admin to create new products so the website now actually communicates with the merchello db tables. But I'm having trouble creating invoices and orders through code.

    My code executes without an error in the frontend or in the logs, but no invoice or order is created in the db. I had to add in a few lines of code to generate the invoice key as well as the invoice item, order and order item keys because it was thrown exceptions.

    When I switch the database and use the one that is hosted on my other host (not on azure) this code works fine, I even don't need to generate any keys and the invoice number is populated correctly. I rebuilt the Examine indexes thinking it may help but it didn't.

    I tried to look for some db functions or triggers that may be missing and causing this but it doesn't look like Merchello uses them.

    Also, this piece of code for creating a product works:

    Product pr = (Product)MerchelloContext.Current.Services.ProductService.CreateProduct("Test from code", "skuuuuu", 1);
                MerchelloContext.Current.Services.ProductService.Save(pr);
    

    But this one for creating an invoice and an order doesn't.

               var invoiceService = Core.MerchelloContext.Current.Services.InvoiceService;
    
                Invoice invoice = (Invoice)invoiceService.CreateInvoice(invoiceStatus);
                invoice.Key = Guid.NewGuid();
    
                invoice.CustomerKey = customer.Key;
                invoice.VersionKey = Guid.NewGuid();
    
                foreach (ILineItem lineItem in basket.Items)
                {
                    InvoiceLineItem item = new InvoiceLineItem(Core.LineItemType.Product, lineItem.Name, lineItem.Sku, lineItem.Quantity, lineItem.Price);
                    item.Key = Guid.NewGuid();
                    invoice.Items.Add(item);
                }
    
                decimal charges = 0;
                foreach (ILineItem item in invoice.Items)
                {
                    if (item.LineItemType != Core.LineItemType.Discount) charges += item.TotalPrice;
                }
    
                decimal discounts = 0;
    
                decimal converted;
                invoice.Total = decimal.TryParse((charges - discounts).ToString(CultureInfo.InvariantCulture), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture.NumberFormat, out converted) ? converted : 0;
    
                var settings = new CheckoutContextSettings()
                {
                    InvoiceNumberPrefix = WebConfigurationManager.AppSettings["Bazaar:InvoiceNumberPrefix"]
                };
    
                invoice.InvoiceNumberPrefix = settings.InvoiceNumberPrefix;
    
                invoiceService.Save(invoice);
    

    Thanks for your time. I really appreciate it. If there is some way to repay you back, please tell me.

Please Sign in or register to post replies

Write your reply to:

Draft