s06e02 - XML Sitemaps SUPPORT / QUESTIONS
s06e02 - XML Sitemaps
@burt, @ecartz or a phoenixcart team member, just wondering if anyone has looked at the making the sitemap code compatible with 1.0.8.7?
Thanks, Doug
Thanks, Doug
Tags:
-
ecartz
- Core Team
- Posts: 3084
- Joined: Tue Nov 05, 2019 6:02 pm
- Phoenix Version:
- Has thanked: 4 times
- Been thanked: 208 times
Re: s06e02 - XML Sitemaps
Burt's position is that if people want updates (or backports), they should contract with one of the certified developers to get them. He's been busy with life outside the internet, so he hasn't been one of the certified developers this year. That may change in the future. But overall, he found supporters' code unprofitable, so he is unlikely to return to the old way of doing things even if he returns full time.
The last time I looked at it was 1.0.8.5. At that time, the categories hook needed to be renamed to catalog hooks. The major change since then was to the shopping cart, which shouldn't affect the site map. I think that just renaming the hook (both the class name and the file name) and adding the two compatibility listeners would make it work.
There's been some talk about creating a more up-to-date version of the supporters' code. I've coded most of it through 1.0.8.5 (the two template releases are the main exception). That's one of the things that I was doing between releases. I've been busy with other projects for the last couple releases, so some things need updated (I still plan to update for 1.0.8.7 this month, while 1.0.8.8 is going through its testing cycle). However, the real holdup is primarily testing and dissemination. We haven't found a good solution so far but are open to suggestions.
The basic problem is that all of myself, Burt, and Heatherbell have enough on our plate and can't add more. Also, since Burt has been busy offline, these discussions don't always move quickly. And of course, we don't have a good way to recruit people to do the leftover tasks.
Anyway, if you're in a real hurry, you could have one of the certified developers test and potentially fix what I have now.
The last time I looked at it was 1.0.8.5. At that time, the categories hook needed to be renamed to catalog hooks. The major change since then was to the shopping cart, which shouldn't affect the site map. I think that just renaming the hook (both the class name and the file name) and adding the two compatibility listeners would make it work.
There's been some talk about creating a more up-to-date version of the supporters' code. I've coded most of it through 1.0.8.5 (the two template releases are the main exception). That's one of the things that I was doing between releases. I've been busy with other projects for the last couple releases, so some things need updated (I still plan to update for 1.0.8.7 this month, while 1.0.8.8 is going through its testing cycle). However, the real holdup is primarily testing and dissemination. We haven't found a good solution so far but are open to suggestions.
The basic problem is that all of myself, Burt, and Heatherbell have enough on our plate and can't add more. Also, since Burt has been busy offline, these discussions don't always move quickly. And of course, we don't have a good way to recruit people to do the leftover tasks.
Anyway, if you're in a real hurry, you could have one of the certified developers test and potentially fix what I have now.
Re: s06e02 - XML Sitemaps
@ecartz I appreciate the tireless support from both yourself and @heatherbell .ecartz wrote: ↑Wed Nov 03, 2021 6:29 am Burt's position is that if people want updates (or backports), they should contract with one of the certified developers to get them. He's been busy with life outside the internet, so he hasn't been one of the certified developers this year. That may change in the future. But overall, he found supporters' code unprofitable, so he is unlikely to return to the old way of doing things even if he returns full time.
The last time I looked at it was 1.0.8.5. At that time, the categories hook needed to be renamed to catalog hooks. The major change since then was to the shopping cart, which shouldn't affect the site map. I think that just renaming the hook (both the class name and the file name) and adding the two compatibility listeners would make it work.
There's been some talk about creating a more up-to-date version of the supporters' code. I've coded most of it through 1.0.8.5 (the two template releases are the main exception). That's one of the things that I was doing between releases. I've been busy with other projects for the last couple releases, so some things need updated (I still plan to update for 1.0.8.7 this month, while 1.0.8.8 is going through its testing cycle). However, the real holdup is primarily testing and dissemination. We haven't found a good solution so far but are open to suggestions.
The basic problem is that all of myself, Burt, and Heatherbell have enough on our plate and can't add more. Also, since Burt has been busy offline, these discussions don't always move quickly. And of course, we don't have a good way to recruit people to do the leftover tasks.
Anyway, if you're in a real hurry, you could have one of the certified developers test and potentially fix what I have now.
As a "Pro Supporter" wish that sitemaps and SEO would keep pace with releases.
Suggestions?
If I had any coding ability may feel confident in making a suggestion or two...
Considering I have none, I will wait for the professionals to fix.
Again thanks and appreciation to @ecartz and @heatherbell for the hard work and support.
-
heatherbell
- Senior Contributor
- Posts: 2540
- Joined: Mon Oct 07, 2019 4:39 am
- Phoenix Version:
- Has thanked: 35 times
- Been thanked: 243 times
Re: s06e02 - XML Sitemaps
As a "Pro Supporter" you receive Supporters Addons for free. Very recently I also re-coded and packaged an addon for you for free. Naturally, I do not commit to giving updates and support to you for that addon in perpetuity for free! The same goes for Supporters Addons although I have always found support is given in the VIP Forum (another benefit of being a PRO Supporter).
There are suggestions in the previous post by ecartz but if you are unsure of what to do, I'm sure if you post the exact details of your issue, further free support would be offered here. Otherwise, if you are convinced that the addon is of value to your business it would be best to contact a Certified Developer to fix it for you as suggested by ecartz.
Re: s06e02 - XML Sitemaps
@ecartz Thanks.ecartz wrote: ↑Wed Nov 03, 2021 6:29 am Burt's position is that if people want updates (or backports), they should contract with one of the certified developers to get them. He's been busy with life outside the internet, so he hasn't been one of the certified developers this year. That may change in the future. But overall, he found supporters' code unprofitable, so he is unlikely to return to the old way of doing things even if he returns full time.
The last time I looked at it was 1.0.8.5. At that time, the categories hook needed to be renamed to catalog hooks. The major change since then was to the shopping cart, which shouldn't affect the site map. I think that just renaming the hook (both the class name and the file name) and adding the two compatibility listeners would make it work.
There's been some talk about creating a more up-to-date version of the supporters' code. I've coded most of it through 1.0.8.5 (the two template releases are the main exception). That's one of the things that I was doing between releases. I've been busy with other projects for the last couple releases, so some things need updated (I still plan to update for 1.0.8.7 this month, while 1.0.8.8 is going through its testing cycle). However, the real holdup is primarily testing and dissemination. We haven't found a good solution so far but are open to suggestions.
The basic problem is that all of myself, Burt, and Heatherbell have enough on our plate and can't add more. Also, since Burt has been busy offline, these discussions don't always move quickly. And of course, we don't have a good way to recruit people to do the leftover tasks.
Anyway, if you're in a real hurry, you could have one of the certified developers test and potentially fix what I have now.
So if I follow correctly.
/includes/hooks/admin/categories needs to be renamed /includes/hooks/admin/catalog
I just created a new folder named catalog and copied the XML_writer.php to it.
/includes/hooks/admin/catalog/XML_writer.php
Changed to
Code: Select all
<?php
/*
Copyright (c) 2020, G Burton
This work is licensed under a
Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.
You should have received a copy of the license along with this work.
If not, see <http://creativecommons.org/licenses/by-nc-nd/4.0/>.
*/
class hook_admin_catalog_XML_writer {
public function listen_copyToConfirmAction() {
xml_writer::do_XML('products');
}
public function listen_deleteProductConfirmAction() {
xml_writer::do_XML('products');
}
public function listen_moveProductConfirmAction() {
xml_writer::do_XML('products');
}
public function listen_productActionSave() {
xml_writer::do_XML('products');
}
public function listen_setFlagAction() {
xml_writer::do_XML('products');
}
public function listen_deleteCategoryConfirmAction() {
xml_writer::do_XML('catalog');
}
public function listen_insertCategoryUpdateCategoryAction() {
xml_writer::do_XML('catalog');
}
public function listen_moveCategoryConfirmAction() {
xml_writer::do_XML('catalog');
}
}
Re: s06e02 - XML Sitemaps
Removed the module, and reinstalled in /admin/dashboard.
Deleted old xml files
Renewed on Dashboard page.
Generates same as previous:
XML_categories_1.xml
XML_manufacturers_1.xml
XML_products_1.xml
Shouldn't it now generate with the code changes
Deleted old xml files
Renewed on Dashboard page.
Generates same as previous:
XML_categories_1.xml
XML_manufacturers_1.xml
XML_products_1.xml
Shouldn't it now generate
Code: Select all
XML_catalog_1.xml-
ecartz
- Core Team
- Posts: 3084
- Joined: Tue Nov 05, 2019 6:02 pm
- Phoenix Version:
- Has thanked: 4 times
- Been thanked: 208 times
Re: s06e02 - XML Sitemaps
The hook needs these as well:
Code: Select all
public function listen_updateProductAction() {
$this->listen_productActionSave();
}
public function listen_insertProductAction() {
$this->listen_productActionSave();
}Re: s06e02 - XML Sitemaps
Can I create a manual sitemap page that reads only the Info pages I want.
so something like:
XML_infopages_1.xml
Thanks, Doug
so something like:
XML_infopages_1.xml
Code: Select all
<url>
<loc>https://www.yoursite.com/info.php?pages_id=Info Page Number</loc>
<lastmod>Add in date created</lastmod>
<changefreq>weekly</changefreq>
<priority>1</priority>
</url>
XML errors saving products
Not sure what I need to change to make it workFatal error: Uncaught Error: Call to undefined function listen_productActionSave() in /includes/hooks/admin/catalog/XML_writer.php:31
Stack trace: #0 /includes/system/versioned/1.0.8.1/hooks.php(150): hook_admin_catalog_XML_writer->listen_updateProductAction(Array)
#1 /admin/includes/segments/process_action.php(19): hooks->cat('updateProductAc...')
#2 /admin/catalog.php(32): require('/home/...')
#3 {main} thrown in /includes/hooks/admin/catalog/XML_writer.php on line 31
/includes/hooks/admin/catalog/XML_writer.php
Code: Select all
<?php
/*
Copyright (c) 2020, G Burton
This work is licensed under a
Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.
You should have received a copy of the license along with this work.
If not, see <http://creativecommons.org/licenses/by-nc-nd/4.0/>.
*/
class hook_admin_catalog_XML_writer {
public function listen_copyToConfirmAction() {
xml_writer::do_XML('products');
}
public function listen_deleteProductConfirmAction() {
xml_writer::do_XML('products');
}
public function listen_moveProductConfirmAction() {
xml_writer::do_XML('products');
}
public function listen_productActionSave() {
xml_writer::do_XML('products');
}
public function listen_setFlagAction() {
xml_writer::do_XML('products');
}
public function listen_updateProductAction() {
listen_productActionSave();
}
public function listen_insertProductAction() {
listen_productActionSave();
}
public function listen_deleteCategoryConfirmAction() {
xml_writer::do_XML('catalog');
}
public function listen_insertCategoryUpdateCategoryAction() {
xml_writer::do_XML('catalog');
}
public function listen_moveCategoryConfirmAction() {
xml_writer::do_XML('catalog');
}
}
Code: Select all
<?php
/*
$Id$
CE Phoenix, E-Commerce made Easy
https://phoenixcart.org
Copyright (c) 2021 Phoenix Cart
Released under the GNU General Public License
*/
class hooks {
protected $_site;
protected $_hooks = [];
const PREFIX = 'listen_';
protected $prefix_length;
protected $pipelines = [];
protected $page;
protected $hook_directories = [];
public function __construct($site) {
$this->_site = basename($site);
$this->prefix_length = strlen(self::PREFIX);
$this->add_directory(DIR_FS_CATALOG . 'includes/hooks/');
}
public function add_directory($directory) {
$this->hook_directories[] = $directory . $this->_site . '/';
}
protected function sort_hooks() {
foreach ( $this->_hooks as &$actions ) {
foreach ( $actions as &$codes ) {
uksort($codes, 'strnatcmp');
}
}
}
protected function build_callback($class, $method) {
if ('' === $class) {
return $method;
}
if (isset($_SESSION[$class]) && is_callable([$_SESSION[$class], $method])) {
return [$_SESSION[$class], $method];
}
if (!class_exists($class)) {
return null;
}
if (is_callable([$class, $method])) {
$m = new \ReflectionMethod($class, $method);
if ($m->isStatic()) {
return [$class, $method];
}
}
return [Guarantor::ensure_global($class), $method];
}
protected function load($group) {
$hooks_query = $GLOBALS['db']->query(sprintf(<<<'EOSQL'
SELECT hooks_action, hooks_code, hooks_class, hooks_method
FROM hooks
WHERE hooks_site = '%s' AND hooks_group = '%s'
EOSQL
, $GLOBALS['db']->escape($this->_site), $GLOBALS['db']->escape($group)));
while ($hook = $hooks_query->fetch_assoc()) {
$callback = $this->build_callback($hook['hooks_class'], $hook['hooks_method']);
if (is_callable($callback)) {
Guarantor::guarantee_all(
$this->_hooks,
$this->_site,
$hook['hooks_action']
)[$hook['hooks_code']] = $callback;
}
}
$this->sort_hooks();
}
protected function register_directory($directory, &$files) {
if ( file_exists($directory) && ( $dir = @dir($directory) ) ) {
while ( $file = $dir->read() ) {
if ( !is_dir("$directory/$file") ) {
$files[] = $file;
}
}
$dir->close();
}
}
public function register($group) {
$group = basename($group);
$files = [];
foreach ($this->hook_directories as $directory) {
$this->register_directory("$directory$group", $files);
}
foreach ($files as $file) {
$pathinfo = pathinfo($file);
if ( 'php' === $pathinfo['extension'] ) {
$class = "hook_{$this->_site}_{$group}_{$pathinfo['filename']}";
foreach ( get_class_methods(Guarantor::ensure_global($class)) as $method ) {
if ( substr($method, 0, $this->prefix_length) === self::PREFIX ) {
$action = substr($method, $this->prefix_length);
Guarantor::guarantee_all($this->_hooks, $this->_site, $action
)[$pathinfo['filename']] = [$GLOBALS[$class], $method];
}
}
}
}
$this->load($group);
}
public function register_page() {
$this->page = pathinfo($GLOBALS['PHP_SELF'], PATHINFO_FILENAME);
$this->register($this->page);
$this->register_pipeline('siteWide');
$this->call('siteWide', 'injectAppTop');
}
public function register_pipeline($pipeline, &$parameters = null) {
$this->register($pipeline);
$this->call($this->page, "{$pipeline}Start", $parameters);
}
public function set($action, $code, $callable) {
$hooks =& Guarantor::guarantee_all($this->_hooks, $this->_site, $action);
$hooks[$code] = $callable;
uksort($hooks, 'strnatcmp');
}
public function call($group, $action, $parameters = []) {
return $this->cat($action, $parameters);
}
public function cat($action, $parameters = []) {
$result = '';
foreach ( @(array)$this->_hooks[$this->_site][$action] as $callback ) {
$result .= call_user_func($callback, $parameters);
}
if ( $result ) {
return $result;
}
}
public function generate($action, $parameters = []) {
foreach ( @(array)$this->_hooks[$this->_site][$action] as $callback ) {
yield call_user_func($callback, $parameters);
}
}
public function chain($action, $parameters = []) {
foreach ( @(array)$this->_hooks[$this->_site][$action] as $callback ) {
$parameters = call_user_func($callback, $parameters);
}
return $parameters;
}
public function get_hook_directories() {
return $this->hook_directories;
}
}
/admin/includes/segments/process_action.php
Code: Select all
<?php
/*
$Id$
CE Phoenix, E-Commerce made Easy
https://phoenixcart.org
Copyright (c) 2021 Phoenix Cart
Released under the GNU General Public License
*/
Guarantor::ensure_global('Admin');
$action = $_GET['action'] ?? '';
$admin_hooks->cat('preAction');
if ($action && ($action_file = $Admin->locate_action($action))) {
$action_redirect = require $action_file;
$admin_hooks->cat(Admin::camel_case($action) . 'Action');
if (is_string($action_redirect) || ($action_redirect instanceof Href)) {
Href::redirect($action_redirect);
}
}
$admin_hooks->cat('postAction');
if (!isset($_SESSION['sessiontoken'])) {
Form::reset_session_token();
}
Code: Select all
<?php
/*
$Id$
CE Phoenix, E-Commerce made Easy
https://phoenixcart.org
Copyright (c) 2021 Phoenix Cart
Released under the GNU General Public License
*/
$always_valid_actions = ['set_flag'];
require 'includes/application_top.php';
$currencies = new currencies();
// calculate category path
if (empty($_GET['cPath'])) {
$current_category_id = 0;
$cPath = '';
} else {
$cPath_array = array_unique(
array_map('intval', explode('_', $_GET['cPath'])),
SORT_NUMERIC);
$cPath = implode('_', $cPath_array);
$current_category_id = end($cPath_array);
}
const DIR_FS_CATALOG_IMAGES = DIR_FS_CATALOG . 'images/';
require 'includes/segments/process_action.php';
// check if the catalog image directory exists
if (is_dir(DIR_FS_CATALOG_IMAGES)) {
if (!Path::is_writable(DIR_FS_CATALOG_IMAGES)) {
$messageStack->add(sprintf(ERROR_CATALOG_IMAGE_DIRECTORY_NOT_WRITEABLE, DIR_FS_CATALOG_IMAGES), 'error');
}
} else {
$messageStack->add(sprintf(ERROR_CATALOG_IMAGE_DIRECTORY_DOES_NOT_EXIST, DIR_FS_CATALOG_IMAGES), 'error');
}
require 'includes/template_top.php';
$base_url = HTTP_SERVER . DIR_WS_ADMIN;
if ($view_file = $Admin->locate('/views', $action)) {
require $view_file;
}
?>
<script>
$(document).on('change', '#cImg, [id^=pImg]', function (event) { $(this).next('.custom-file-label').html(event.target.files[0].name); });
</script>
<?php
require 'includes/template_bottom.php';
require 'includes/application_bottom.php';
?>
-
Omar_one
- Senior Contributor
- Posts: 677
- Joined: Fri Oct 25, 2019 5:06 pm
- Phoenix Version: v1.0.8.16
- Has thanked: 100 times
- Been thanked: 56 times
Re: XML errors saving products
I changed this lines in /includes/hooks/admin/catalog/XML_writer.php (I am not sure if this right but the error not shown any more)
to this
Code: Select all
public function listen_updateProductAction() {
listen_productActionSave();
}
public function listen_insertProductAction() {
listen_productActionSave();
}Code: Select all
public function listen_updateProductAction() {
xml_writer::do_XML('products');
}
public function listen_insertProductAction() {
xml_writer::do_XML('products');
}