Is there a way to connect to Magento Database from a C # application?

I would like to create an application to access (read / write) a magento database using C #. I am wondering if there is a way to connect from a user application? If so, what would be better? Please suggest me as I'm new to Magento, thanks.

+4
source share
2 answers

You can do this using the magento API, the code below can help you;

using Magento_Import.MagentoAPI;

namespace Magento_Import
{
    public partial class _Default : System.Web.UI.Page
    {
        Mage_Api_Model_Server_V2_HandlerPortTypeClient handler = new Mage_Api_Model_Server_V2_HandlerPortTypeClient();

        protected void Page_Load(object sender, EventArgs e)
        {
            string session = handler.login("username", "password");

            catalogProductEntity[] products;
            handler.catalogProductList(out products, session, null, null);
        }
    }
}
0
source

I use LINQPad (C #, VB.NET, F #) every day to connect to my Magento database through SSH tunneling.

MySQL, LINQ to SQL Magento.

, , LINQPad:

var items =
    from o in sales_flat_order
    where o.created_at > DateTime.Now.AddDays(-100)
    join i in sales_flat_order_item on o.entity_id equals i.order_id
    where i.sku.Contains(sku)
    join p in sales_flat_order_payment on o.entity_id equals p.parent_id
    orderby o.created_at descending
    select new
    {
        timestamp = o.created_at,
        order = o.increment_id,
        i.sku,
        i.name,
        qty = i.qty_ordered,
        o.status,
        p.method,
        i.row_total_incl_tax,
    };

, .

SELECT t0.created_at, t0.increment_id, t1.sku, t1.name, t1.qty_ordered, t0.status, t2.method, t3.qty, t1.row_total_incl_tax
FROM sales_flat_order AS t0
INNER JOIN sales_flat_order_item AS t1
  ON (t0.entity_id = t1.order_id)
INNER JOIN sales_flat_order_payment AS t2
  ON (t0.entity_id = t2.parent_id)
INNER JOIN (
  SELECT t4.sku, t5.qty
  FROM catalog_product_entity AS t4
  INNER JOIN cataloginventory_stock_item AS t5
    ON (t4.entity_id = t5.product_id)
  WHERE (t4.sku LIKE CONCAT('%',@p0,'%'))
  ) AS t3
  ON (t1.sku = t3.sku)
WHERE ((t0.created_at > @p1) AND (t1.sku LIKE CONCAT('%',@p0,'%')))
ORDER BY t0.created_at DESC
-- p0 = [LEFCACP01]
-- p1 = [2015-08-07 16:13:31]

.NET ..

chart

.

LINQPad

+1

Source: https://habr.com/ru/post/1615682/


All Articles