Post by vreyesim » Tue Feb 13, 2018 11:41 pm

try to call all image links in a xml file.

these are loaded
$this->load->model('catalog/product');
$this->load->model('catalog/category');
$this->load->model('tool/image')

i guess product images described in catalog/controller/product/product.php
$data['images'] = array();
$results = $this->model_catalog_product->getProductImages($this->request->get['product_id']);
foreach ($results as $result) {
$data['images'][] = array(
'popup' => $this->model_tool_image->resize($result['image'], $this->config->get('config_image_popup_width'), $this->config->get('config_image_popup_height')),
'thumb' => $this->model_tool_image->resize($result['image'], $this->config->get('config_image_additional_width'), $this->config->get('config_image_additional_height'))
);
}

this works well, shows main image (https://www.example.com/image/cache/catalog/105.jpg)
$output .= '<images>' . $this->model_tool_image->resize($product['image'], $this->config->get('config_image_popup_width'), $this->config->get('config_image_popup_height')) . '</images>';[/b]

this does not work to take the images
$product['images'] = array();
$results = $this->model_catalog_product->getProductImages($product['product_id']);
foreach ($results as $result) {
foreach ($result['image'] as $value)

);
}

which variable and how should i use with array ?

what i need is to see images of one product
<image>https://www.example.com/image/cache/cat ... jpg</image>
<image>https://www.example.com/image/cache/cat ... jpg</image>
<image>https://www.example.com/image/cache/cat ... jpg</image>

New member

Posts

Joined
Sun Jan 28, 2018 2:34 am

Post by straightlight » Wed Feb 14, 2018 6:56 am

Partial information posted. More information is needed.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by vreyesim » Wed Feb 14, 2018 2:19 pm

<?php
class ControllerFeedXmlFeed extends Controller {
public function index() {
if ($this->config->get('xmlfeed_status')) {
$output = '<?xml version="1.0" encoding="UTF-8"?>';
$output .= '<Products xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">';
$this->load->model('catalog/product');
$this->load->model('catalog/category');
$this->load->model('tool/image');
$products = $this->model_catalog_product->getProducts();
foreach ($products as $product) {
if($product['quantity'] > 2700)
if ($product['image']) {
$output .= '<Product>';
$output .= '<id>' . $product['product_id'] . '</id>';
$output .= '<ProductName>' . $product['name'] . '</ProductName>';
if ($product['model']) {
................................... (lines).............................................
$output .= '<FullCategoryPath>' . $string . '</FullCategoryPath>';
$output .= '<description><![CDATA['. $product['description'] . ']]></description>';
$output .= '<link>' . $this->url->link('product/product', 'product_id=' . $product['product_id']) . '</link>';
$output .= '<image_link>' . $this->model_tool_image->resize($product['image'], $this->config->get('config_image_popup_width'), $this->config->get('config_image_popup_height')) . '</image_link>';
1- xmlfeed.xml file is under catalog/controller/feed. $output .= '<image_link>' retrieve main image link but extra images.
need this result here
<image_link>www.example.com/image/picture1.jpg </image_link>
<image_link>www.example.com/image/picture2.jpg </image_link>
<image_link>www.example.com/image/picture3.jpg </image_link>
2- Also try to understand the structure. $this->load->model('catalog/product') and $this->load->model('tool/image') this part carries the variables. $data['images'] is described in product.php. i can not use this variable in xmlfeed.xml file. Why ?(sorry for foreigner English)
$output .= '</Product>';
}
}
$output .= '</Products>';
$this->response->addHeader('Content-Type: application/xml');
$this->response->setOutput($output);
}
}
protected function getPath($parent_id, $current_path = '') {
$category_info = $this->model_catalog_category->getCategory($parent_id);
if ($category_info) {
if (!$current_path) {
$new_path = $category_info['category_id'];
} else {
$new_path = $category_info['category_id'] . '_' . $current_path;
}
$path = $this->getPath($category_info['parent_id'], $new_path);
if ($path) {
return $path;
} else {
return $new_path;
}
}
}
}

New member

Posts

Joined
Sun Jan 28, 2018 2:34 am
Who is online

Users browsing this forum: No registered users and 21 guests