Jump to content

Recommended Posts

Задали тут задачку сделать карту сайта для изображений sitemap_img.xlm

Вот так должен выглядеть xml для картинок

<?xml version="1.0" encoding="UTF-8"?>
  <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
   xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">
  <url>
    <loc>http://example.com/sample.html</loc>
    <image:image>
        <image:loc>http://example.com/image.jpg</image:loc>
    </image:image>
  </url>
</urlset> 

Код из Seo Pack Pro - формирует стандартный sitemap.xml

<?php
class ControllerFeedGoogleSitemapExtra extends Controller {
   public function index() {
	  if ($this->config->get('google_sitemap_status')) {
		 $output  = '<?xml version="1.0" encoding="UTF-8"?>';
		 $output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
		 $output .= '<url>';
		 $output .= '<loc>' . HTTP_SERVER . '</loc>';
		 $output .= '<changefreq>weekly</changefreq>';
		 $output .= '<priority>1.0</priority>';
		 $output .= '</url>';
		 
		 $fields = array();
		 $query = $this->db->query("SELECT DISTINCT ua.keyword FROM " . DB_PREFIX . "url_alias ua INNER JOIN " . DB_PREFIX . "language l on l.language_id = ua.language_id where l.code = '". $_GET["language"] ."';");
		 $fields = $query->rows;
		 $squery = $this->db->query("SELECT `value` FROM `" . DB_PREFIX . "setting` WHERE `key` = 'config_language'");
		 
		 foreach ($fields as $field) {
			$output .= '<url>';
			$output .= '<loc>' . HTTP_SERVER . (($_GET["language"] <> $squery->row['value']) ? ($_GET["language"] . '/') : '') . $field['keyword'] . '</loc>';
			$output .= '<image:image>';
			
            $output .= '<image:loc>'. HTTP_SERVER .'/image.jpg</image:loc>';
			
            $output .= '</image:image>';
			$output .= '<changefreq>weekly</changefreq>';
			$output .= '<priority>1.0</priority>';
			$output .= '</url>';   
		 }
		 
		 $output .= '</urlset>';
		 
		 $this->response->addHeader('Content-Type: application/xml');
		 $this->response->setOutput($output);
	  }
   }  
     
}
?>

Доделать по идее не  сложно. Момогите достать адреса картинок на карточке товара. Напрямую из базы вытаскивать я так понимаю - неправильно.

Т.к. у меня на карточке товара ссылки на картинки выглядят так:

<div class="image"><a id="first-a" href="http://site.com/image/cache/data/Brand_34030_2-700x700.JPG" title="Title_img" ><img src="http://site.com/image/cache/data/Brand_34030_2-420x420.JPG" data-zoom-image="http://site.com/image/cache/data/Brand_34030_2-700x700.JPG" title="Title_img" alt="" id="image" /></a></div>
                  <div class="gallery_text"><span>Кликните на изображение</span><img src="catalog/view/theme/journal/images/product_zoom.png" alt="" /></div>
                  <div class="image-additional">
                <a href="http://site.com/image/cache/data/Brand_34030_2-700x700.JPG" title="Title_img"><img src="http://site.com/image/cache/data/Brand_34030_2-420x420.JPG" title="Title_img" alt="" id="image_2" /></a>
                        <a href="http://site.com/image/cache/data/Brand_34030_3-700x700.JPG" title="Title_img"><img src="http://site.com/image/cache/data/Brand_34030_3-80x80.JPG" data-zoom-image="http://site.com/image/cache/data/Brand_34030_3-700x700.JPG" title="Title_img" alt="" /></a>
                <a href="http://site.com/image/cache/data/Brand_34030_5-700x700.JPG" title="Title_img"><img src="http://site.com/image/cache/data/Brand_34030_5-80x80.JPG" data-zoom-image="http://site.com/image/cache/data/Brand_34030_5-700x700.JPG" title="Title_img" alt="" /></a>
              </div>
            <!-- swipebox gallery -->
        <div style="display: none;" id="swipebox">
                <a href="http://site.com/image/cache/data/Brand_34030_2-700x700.JPG" title="Title_img" rel="product-gallery" class="swipebox"><img src="http://site.com/image/cache/data/Brand_34030_2-420x420.JPG" title="Title_img" alt="" /></a>
                        <a href="http://site.com/image/cache/data/Brand_34030_3-700x700.JPG" title="Title_img" rel="product-gallery" class="swipebox"><img src="http://site.com/image/cache/data/Brand_34030_3-80x80.JPG" data-zoom-image="http://site.com/image/cache/data/Brand_34030_3-700x700.JPG" title="Title_img" alt="" /></a>
                <a href="http://site.com/image/cache/data/Brand_34030_5-700x700.JPG" title="Title_img" rel="product-gallery" class="swipebox"><img src="http://site.com/image/cache/data/Brand_34030_5-80x80.JPG" data-zoom-image="http://site.com/image/cache/data/Brand_34030_5-700x700.JPG" title="Title_img" alt="" /></a>
                </div>

Уткуда можно вытащить список кешированных картинок для карточки товара?

Share this post


Link to post
Share on other sites

Скачайте с офсайта оригинальный опенкарт - в нем есть кусок кода, который это реализует, но реально если у вас не сформировался кеш картинок, процесс будет умирать на 200-300ом товаре!

Share this post


Link to post
Share on other sites

Скачал. Где искать? На что ориентироваться? В google_sitemap.php нет такого.

Share this post


Link to post
Share on other sites
 if ($product['image']) {
			$output .= '<url>';
			$output .= '<loc>' . $this->url->link('product/product', 'product_id=' . $product['product_id']) . '</loc>';
			$output .= '<changefreq>weekly</changefreq>';
			$output .= '<priority>1.0</priority>';
			$output .= '<image:image>';
			$output .= '<image:loc>' . $this->model_tool_image->resize($product['image'], $this->config->get('config_image_popup_width'), $this->config->get('config_image_popup_height')) . '</image:loc>';
			$output .= '<image:caption>' . $product['name'] . '</image:caption>';
			$output .= '<image:title>' . $product['name'] . '</image:title>';
			$output .= '</image:image>';
			$output .= '</url>';   
		 }

https://github.com/opencart/opencart/blob/master/upload/catalog/controller/feed/google_sitemap.php

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.