Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
有没有办法从c#应用程序连接到Magento数据库?_C#_Magento - Fatal编程技术网

有没有办法从c#应用程序连接到Magento数据库?

有没有办法从c#应用程序连接到Magento数据库?,c#,magento,C#,Magento,我想使用c#构建一个应用程序来访问(读/写)magento数据库。我想知道有没有办法从自定义应用程序进行连接?如果是,哪一个最好?请推荐我,因为我是Magento的新手,谢谢。您可以使用Magento API来实现这一点,下面的代码可能会对您有所帮助 using Magento_Import.MagentoAPI; namespace Magento_Import { public partial class _Default : System.Web.UI.Page {

我想使用c#构建一个应用程序来访问(读/写)magento数据库。我想知道有没有办法从自定义应用程序进行连接?如果是,哪一个最好?请推荐我,因为我是Magento的新手,谢谢。

您可以使用Magento API来实现这一点,下面的代码可能会对您有所帮助

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);
        }
    }
}
我每天使用(C#,VB.NET,F#)通过SSH隧道连接到我的Magento数据库

有一个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,
    };
然后,该工具允许您查看发送到DB的实际查询

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控件来执行图表绘制等

我将其用于各种数据库报告和维护活动


您是一名c#开发人员?那么您就不能使用LINQPad访问您的Magento数据库。我使用它来完成很多数据库维护任务。如果你愿意,我很乐意与你讨论。如果你想聊天,也许可以将我的旧id添加到Skype中。@Enigmativity是的,可以给我你的用户id吗?谢谢你的提议。我的Skype id是我的SO id。