Автор Тема: экспорт XML  (Прочитано 740 раз)

14 Июль 2016, 16:14:39
  • Пользователь
  • **
  • Сообщений: 75
  • Репутация: +1/-0
  • Сообщество PrestaShop
    • Просмотр профиля
Подскажите пожалуйста как получить все изображения с карточки товара. Переделываю модуль яндекс маркет.

Есть такой код генерирует одно изображение
$offer->picture = $this->context->link->getImageLink($product['link_rewrite'], $product['id_image']);
Думою что начало вот так:

$images = array();
....
$offer->picture = $images;
14 Июль 2016, 16:33:55
Ответ #1
  • Модератор
  • Ветеран
  • *****
  • Сообщений: 33325
  • Репутация: +26771/-0
    • Просмотр профиля
// переменная со всеми изображениями
$pictures = $this->getPictures($product['id_product'], $product['link_rewrite']);

// функция
private function getPictures($id_product, $link_rewrite)
{
        $pictures = array();
        $images = Image::getImages($this->id_lang, $id_product);
        foreach ($images AS $image) {
           $pictures[] = $this->context->link->getImageLink($link_rewrite, $id_product.'-'.$image['id_image'], $this->image_type);
        }
        return $pictures;
}
14 Июль 2016, 17:00:12
Ответ #2
  • Пользователь
  • **
  • Сообщений: 75
  • Репутация: +1/-0
  • Сообщество PrestaShop
    • Просмотр профиля
добавил   ваш код
private function getPictures($id_product, $link_rewrite)
{
        $pictures = array();
        $images = Image::getImages($this->id_lang, $id_product);
        foreach ($images AS $image) {
           $pictures[] = $this->context->link->getImageLink($link_rewrite, $id_product.'-'.$image['id_image'], $this->image_type);
        }
        return $pictures;
}
private function _addProduct($shop, $product, $combination = false)
{
$quantity = (int)($combination?$combination['quantity']:$product['quantity']);

//В наличии или под заказ
$available = 'false';
if ($this->yamarket_availability == 0)
$available = 'true';
elseif ($this->yamarket_availability == 1)
{
if ($quantity > 0)
$available = 'true';
}
elseif ($this->yamarket_availability == 2)
{
$available = 'true';
if ($quantity == 0)
return;
}

$offer = new ymlOffer($product['id_product'].($combination?'c'.$combination['id_product_attribute']:''),
'',
$available
);
$offer->url = $product['link'].($combination?'#'.$combination['comb_url']:'');
$offer->price = Tools::ps_round(($combination?$combination['price']:$product['price']), 2);
$offer->currencyId = $this->currency_iso;
$offer->categoryId = $product['id_category_default'];


        //добавил   
                $offer->param = $pictures;


 $offer->picture = $this->context->link->getImageLink($product['link_rewrite'], $product['pictures']);
       


$offer->name = $product['name'];
$offer->vendor = $product['manufacturer_name'];
$offer->vendorCode = ($combination?$combination['reference']:$combination['reference']);
$offer->description = $product['description'];
$offer->sales_notes = Configuration::get('yamarket_info');
$offer->barcode = ($combination?$combination['ean13']:$combination['ean13']);
if (isset($this->yamarket_shipping[1]) && $this->yamarket_shipping[1])
$offer->delivery = 'true';
if (isset($this->yamarket_shipping[2]) && $this->yamarket_shipping[2])
$offer->pickup = 'true';
if (isset($this->yamarket_shipping[3]) && $this->yamarket_shipping[3])
$offer->store = 'true';
$params = array();
if ($product['features'])
foreach ($product['features'] as $feature)
$params[$feature['name']] = $feature['value'];
if ($combination)
$params = array_merge($params, $combination['attributes']);
$offer->param = $params;

$shop->add($offer);
}

Что-то не работает. Можете подсказать.
14 Июль 2016, 17:28:44
Ответ #3
  • Модератор
  • Ветеран
  • *****
  • Сообщений: 22125
  • Репутация: +25303/-1
  • Prestashop - просто и эффективно
    • Просмотр профиля
Когда у товара есть комбинации то работать не будет. Для комбинаций нужно определять свой массив изображений.
Эксперт Prestashop - решения всех проблем, написание модулей, создание тем для интернет-магазинов под Prestashop.
Эксперт Magento - создам сайт на Magento, программирование кастомных модулей для Magento, кастомизация тем Magento.
Лучшие цены!!!
14 Июль 2016, 17:31:08
Ответ #4
  • Пользователь
  • **
  • Сообщений: 75
  • Репутация: +1/-0
  • Сообщество PrestaShop
    • Просмотр профиля
Комбинаций нет
14 Июль 2016, 17:34:51
Ответ #5
  • Модератор
  • Ветеран
  • *****
  • Сообщений: 22125
  • Репутация: +25303/-1
  • Prestashop - просто и эффективно
    • Просмотр профиля
Тогда проверять нужно передачу переменных в функцию и иницилизацию внутренних переменных.
Эксперт Prestashop - решения всех проблем, написание модулей, создание тем для интернет-магазинов под Prestashop.
Эксперт Magento - создам сайт на Magento, программирование кастомных модулей для Magento, кастомизация тем Magento.
Лучшие цены!!!