экспорт XML

Автор Kirik1982, 14 июля 2016, 16:14:39

« назад - далее »

Kirik1982

Подскажите пожалуйста как получить все изображения с карточки товара. Переделываю модуль яндекс маркет.

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

Думою что начало вот так:

$images = array();
....
$offer->picture = $images;

coder

// переменная со всеми изображениями
$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;
}

Kirik1982

#2
добавил   ваш код
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);
}


Что-то не работает. Можете подсказать.

PrestaMan

Когда у товара есть комбинации то работать не будет. Для комбинаций нужно определять свой массив изображений.
Эксперт Prestashop - решения всех проблем, написание модулей, создание тем для интернет-магазинов под Prestashop.
Эксперт Magento - создам сайт на Magento, программирование кастомных модулей для Magento, кастомизация тем Magento.
Лучшие цены!!!

Kirik1982

Комбинаций нет

PrestaMan

Тогда проверять нужно передачу переменных в функцию и иницилизацию внутренних переменных.
Эксперт Prestashop - решения всех проблем, написание модулей, создание тем для интернет-магазинов под Prestashop.
Эксперт Magento - создам сайт на Magento, программирование кастомных модулей для Magento, кастомизация тем Magento.
Лучшие цены!!!