使用 API 在 prestashop 中获取产品 URL

Get Products URLs in prestashop using API

我目前正在使用 Microsoft bot Framework 使用 .NET 开发 ChatBot 我创建了可用产品列表并使用 Herocard 在轮播中显示该列表并放置一个按钮 BUY 当客户单击它时将他带到页面产品所在的位置问题是我如何使用其 ID 获得产品 url,以便我可以将其放入按钮 BUY

 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)
            {
                ;
                List<CardImage> cardImages = new List<CardImage>();
                cardImages.Add(new CardImage(url: $"http://test.com/123456.jpg"));
                List <CardAction> cardButtons = new List<CardAction>();
                CardAction plButton = new CardAction()

                {
                    Value =$"i don't know what i should put here",
                    Type = "openUrl",
                    Title = "Buy"
                };
                cardButtons.Add(plButton);
                HeroCard plCard = new HeroCard()
                {
                    Title = l.Value,
                    Subtitle = (p.price.ToString("C", Cultures.usa)),
                    Images = cardImages,
                    Buttons = cardButtons
                };
                Attachment plAttachment = plCard.ToAttachment();
                replyMessage.Attachments.Add(plAttachment);
            }

        }
    }

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

http://localhost:8080/prestashopdemo/index.php?controller=product&id_product="+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);
                }

            }