Мне удалось подключиться к нему, и я хочу получить продукт по его SKU. Я решил поискать существующий SKU и написал этот код:
Код: Выделить всё
private void button1_Click(object sender, EventArgs e)
{
var client = new MagentoApi()
.SetCustomAdminUrlPart("index.php/admin")
.Initialize("http://www.example.com/magento/",
"57348583384fh8h83h4334h34", "8vh388hhfh487f34h8hiuw3")
.AuthenticateAdmin("admin", "adminpassword");
textBox1.AppendText("Connection successfull \n");
Application.DoEvents();
textBox1.AppendText("Looking for product with sku:" + "convertor-touchscreen \n");
Application.DoEvents();
var response = client.GetProductBySku("convertor-touchscreen").Result;
textBox1.AppendText("Done locating product \n");
Application.DoEvents();
...
}
- Сначала я запустил приложение, но оно зависло сразу после отображения сообщения «Ищу товар с артикулом...»< /p>
- Затем я запустил Fiddler, чтобы посмотреть, что происходит, и, к удивлению, мой запрос вернул действительный ответ... Я ожидаю, что мое приложение добавит новую строку в мое текстовое поле... но мое приложение решает зависнуть.
Подключение успешно. Ищу продукт с
артикул:конвертер-сенсорный экран
Почему в мое приложение никогда не приходит ответ?
Итак, вот что я получаю (согласно Fiddler) в TextView:
Код: Выделить всё
{
"10": {
"entity_id": "10",
"attribute_set_id": "4",
"type_id": "simple",
"sku": "convertor-touchscreen",
"name": "Convertor touchscreen",
"meta_title": null,
"meta_description": null,
"url_key": "convertor-touchscreen",
"custom_design": null,
"page_layout": null,
"options_container": "container1",
"country_of_manufacture": null,
"msrp_enabled": "2",
"msrp_display_actual_price_type": "4",
"gift_message_available": null,
"creareseo_discontinued": null,
"creareseo_discontinued_product": null,
"description": "Convertor touchscreen",
"short_description": "Convertor touchscreen",
"meta_keyword": null,
"custom_layout_update": null,
"price": "421.0000",
"special_price": "380.0000",
"weight": "0.1500",
"msrp": null,
"special_from_date": "2015-11-24 00:00:00",
"special_to_date": "2015-11-26 00:00:00",
"news_from_date": null,
"news_to_date": null,
"custom_design_from": null,
"custom_design_to": null,
"status": "1",
"visibility": "4",
"tax_class_id": "2",
"featured": "1"
}
}
Почему мое приложение зависает? Как мне обойти это, чтобы как-то интерпретировать это?
Я хочу иметь доступ к атрибутам продукта из JSON, который, кажется, возвращает< /п>
Подробнее здесь: https://stackoverflow.com/questions/339 ... zes-my-app