Post by Majnoon » Sun May 09, 2021 10:09 pm

Hi guys/girls,
I am in need of help to create a review feed xml for my opencart store 3.0.3.5. The idea is to create a review feed xml file and pull it via feed url in google merchant centre.
https://developers.google.com/product-r ... eds/sample

Active Member

Posts

Joined
Fri Feb 05, 2021 8:29 pm

Post by thekrotek » Sun May 09, 2021 10:54 pm

You can post a request in Commercial Support section.

Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com


User avatar
Expert Member

Posts

Joined
Sun Jul 03, 2016 12:24 am


Post by khnaz35 » Mon May 10, 2021 3:08 pm

Ah, so some one else also have the same thing to be achive.
I have started work on this xml feed will share my code soon as i got some positive out come.

Urgent Questions shoot here: khnaz35@gmail.com
Enjoy nature ;) :) :-*


User avatar
Active Member

Posts

Joined
Mon Aug 27, 2018 11:30 pm
Location - Malaysia

Post by khnaz35 » Mon May 10, 2021 9:45 pm

Just an update i have been working on the extension was able to do the admin part but got a stuck with catalog controller need a little help guys.
I have tried using this way

Code: Select all

<?php
class ControllerExtensionFeedGoogleReview extends Controller {
	public function index() {
		if ($this->config->get('feed_google_review_status')) {
			$output  = '<?xml version="1.0" encoding="UTF-8"?>';
			$output .= '<urlset xmlns="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.google.com/shopping/reviews/schema/product/2.3/product_reviews.xsd">';

			$this->load->model('catalog/review');
			

			$reviews = $this->model_catalog_product->getReviewsByProductId($product_id, $start = 0, $limit = 20);

			foreach ($reviews as $review) {
				$output .= '<url>';
				$output .= '  <loc>' .                         . '</loc>';
				$output .= '  <changefreq>weekly</changefreq>';
				$output .= '  <priority>0.5</priority>';
				$output .= '</url>';
			}

			$output .= '</urlset>';
				}
		
		return $output;
	}
}

Urgent Questions shoot here: khnaz35@gmail.com
Enjoy nature ;) :) :-*


User avatar
Active Member

Posts

Joined
Mon Aug 27, 2018 11:30 pm
Location - Malaysia

Post by ahimanshu » Sat Mar 25, 2023 5:24 am

hi is there any update about this module/extension my website need it can you help me to update this code.

Regards
Himanshu


User avatar
New member

Posts

Joined
Mon Jul 10, 2017 10:55 am
Location - New Delhi

Post by ahimanshu » Sun Mar 26, 2023 6:37 pm

khnaz35 wrote:
Mon May 10, 2021 9:45 pm
Just an update i have been working on the extension was able to do the admin part but got a stuck with catalog controller need a little help guys.
I have tried using this way

Code: Select all

<?php
class ControllerExtensionFeedGoogleReview extends Controller {
	public function index() {
		if ($this->config->get('feed_google_review_status')) {
			$output  = '<?xml version="1.0" encoding="UTF-8"?>';
			$output .= '<urlset xmlns="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.google.com/shopping/reviews/schema/product/2.3/product_reviews.xsd">';

			$this->load->model('catalog/review');
			

			$reviews = $this->model_catalog_product->getReviewsByProductId($product_id, $start = 0, $limit = 20);

			foreach ($reviews as $review) {
				$output .= '<url>';
				$output .= '  <loc>' .                         . '</loc>';
				$output .= '  <changefreq>weekly</changefreq>';
				$output .= '  <priority>0.5</priority>';
				$output .= '</url>';
			}

			$output .= '</urlset>';
				}
		
		return $output;
	}
}
Hello i am upload the quote Opencart 3.0.3.3 catalog/controller/extension/feed/google_review.php with correction

Code: Select all

<?php
class ControllerExtensionFeedGoogleReview extends Controller {
	public function index() {
		if ($this->config->get('feed_google_review_status')) {
			$output  = '<?xml version="1.0" encoding="UTF-8"?>';
			$output .= '<urlset xmlns="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.google.com/shopping/reviews/schema/product/2.3/product_reviews.xsd">';

			$this->load->model('extension/feed/google_review');
			$this->load->model('catalog/review');
			$this->load->model('catalog/product');
			$this->load->model('catalog/category');
			

			$reviews = $this->model_catalog_product->getReviewsByProductId($product_id, $start = 0, $limit = 20);

			foreach ($reviews as $review) {
				$output .= '<url>';
				$output .= '  <loc>' . $this->url->link('product/review', 'product_id=' . $product['product_id']) . '</loc>';
				$output .= '  <changefreq>weekly</changefreq>';
				$output .= '  <priority>0.5</priority>';
				$output .= '</url>';
			}

			$output .= '</urlset>';
				}
		
		return $output;
	}
}
Also update the new code in admin/controller/extension/feed/google_review.php

Code: Select all

<?php
class ControllerExtensionFeedGoogleSitemap extends Controller {
	private $error = array();

	public function index() {
		$this->load->language('extension/feed/google_review');

		$this->document->setTitle($this->language->get('heading_title'));

		$this->load->model('setting/setting');

		if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
			$this->model_setting_setting->editSetting('feed_google_review', $this->request->post);

			$this->session->data['success'] = $this->language->get('text_success');

			$this->response->redirect($this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=feed', true));
		}

		if (isset($this->error['warning'])) {
			$data['error_warning'] = $this->error['warning'];
		} else {
			$data['error_warning'] = '';
		}

		$data['breadcrumbs'] = array();

		$data['breadcrumbs'][] = array(
			'text' => $this->language->get('text_home'),
			'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true)
		);

		$data['breadcrumbs'][] = array(
			'text' => $this->language->get('text_extension'),
			'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=feed', true)
		);

		$data['breadcrumbs'][] = array(
			'text' => $this->language->get('heading_title'),
			'href' => $this->url->link('extension/feed/google_review', 'user_token=' . $this->session->data['user_token'], true)
		);

		$data['action'] = $this->url->link('extension/feed/google_review', 'user_token=' . $this->session->data['user_token'], true);

		$data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=feed', true);

		if (isset($this->request->post['feed_google_review_status'])) {
			$data['feed_google_review_status'] = $this->request->post['feed_google_review_status'];
		} else {
			$data['feed_google_review_status'] = $this->config->get('feed_google_review_status');
		}

		$data['data_feed'] = HTTP_CATALOG . 'index.php?route=extension/feed/google_review';

		$data['header'] = $this->load->controller('common/header');
		$data['column_left'] = $this->load->controller('common/column_left');
		$data['footer'] = $this->load->controller('common/footer');

		$this->response->setOutput($this->load->view('extension/feed/google_review', $data));
	}

	protected function validate() {
		if (!$this->user->hasPermission('modify', 'extension/feed/google_review')) {
			$this->error['warning'] = $this->language->get('error_permission');
		}

		return !$this->error;
	}
}


After that result front page url https://www.patoys.in/index.php?route=e ... gle_review is showing dead (white screen),
in admin dashboard showing 4 feeds with "heading_title" instead of "google_review" action is installed and status is showing Disabled which we are unable to edit, when click on edit we got HTTP ERROR 500. Please help me.

Regards
Himanshu


User avatar
New member

Posts

Joined
Mon Jul 10, 2017 10:55 am
Location - New Delhi

Post by by mona » Mon Mar 27, 2023 3:50 am

You are not outputting anything, just look at the normal google sitemap extension to learn how to send output to the response class and send the right content type header.
Besides, I do not see where the values for $product_id and $product['product_id'] in your code come from?
Last, the status of extensions is generally set in the setting table, check other extensions on how this is done.

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am
Who is online

Users browsing this forum: No registered users and 83 guests