public static function fetchOrder($campaignId, $orderId, string $contentType = null)
{
$config = Configuration::getDefaultConfiguration()
- ->setApiKey('Api-Key', Yii::$app->params['YANDEX_MARKET_API_KEY']);
+ ->setApiKey('Api-Key', Yii::$app->params['YANDEX_MARKET_API_KEY']);
$apiInstance = new OrdersApi(new Client(), $config);
if ($contentType === null) {
public static function saveFromDeliveryText(int $orderId, string $deliveryText): bool
{
$order = MarketplaceOrders::find()->where(['id' => $orderId])->one();
- $model = new MarketplaceOrderDelivery();
- $model->order_id = $orderId;
+
+ // Ищем существующую доставку или создаем новую
+ $model = MarketplaceOrderDelivery::findOne(['order_id' => $orderId]);
+ if (!$model) {
+ $model = new MarketplaceOrderDelivery();
+ $model->order_id = $orderId;
+ }
+
+ // Обновляем данные доставки (могут измениться в последующих письмах)
$model->country = 'Россия';
$model->postcode = null;
$model->apartment = null;