使用API​​在pre​​stashop中获取产品网址

时间:2017-04-21 08:55:02

标签: c# api url prestashop bots

我目前正在使用Microsoft bot Framework开发一个带有.NET的ChatBot我创建了可用产品列表,并使用Herocard在carousel中显示列表,并在客户端点击它时按下按钮将其带到页面所在的页面产品位于问题是如何使用其ID获取产品网址所以我可以把它放在按钮购买

<header class="header {if ($page_name == 'index' || $page_name == 'product') && $marty.get.id_product== 2}transparent{/if}">
</header>

1 个答案:

答案 0 :(得分:0)

我使用下面的网址解决了这个问题:

http://localhost:8080/prestashopdemo/index.php?controller=product&id_product=&#34 + p.id

所以我的代码现在工作得很好

List<product> c = ListProduct.GetProductList();

        List<Bukimedia.PrestaSharp.Entities.AuxEntities.language> lan = new List<Bukimedia.PrestaSharp.Entities.AuxEntities.language>();
        foreach (product p in c)
        {
            lan = p.name;
            foreach (Bukimedia.PrestaSharp.Entities.AuxEntities.language l in lan.Where(l => l.id == 2))
            {

                {

                    List<CardImage> cardImages = new List<CardImage>();
                    cardImages.Add(new CardImage(url: $"http://1234456789@localhost:8080/prestashopdemo/" + p.id_default_image + "-large_default/" + l.Value + ".jpg"));

                    List<CardAction> cardButtons = new List<CardAction>();
                    CardAction plButton = new CardAction()

                    {
                        Value = $"http://localhost:8080/prestashopdemo/index.php?controller=product&id_product="+p.id,
                        Type = "openUrl",
                        Title = "Buy"
                    };
                    cardButtons.Add(plButton);
                    HeroCard plCard = new HeroCard()
                    {
                        Title = l.Value,
                        Subtitle = (p.price.ToString("C")),
                        Images = cardImages,
                        Buttons = cardButtons
                    };
                    Attachment plAttachment = plCard.ToAttachment();
                    replyMessage.Attachments.Add(plAttachment);
                }

            }
相关问题