Post by Hourglasss » Mon Feb 12, 2024 11:26 am

GEtting a php error and blank page when trying to edit an product

Code: Select all

PHP Fatal error:  Cannot declare class Opencart\\Admin\\Model\\Catalog\\Attribute, because the name is already in use in /var/www/html/opencart/extension/ocmod/admin/model/catalog/attribute.php on line 10, referer: https://www.xx.com/xx/index.php?route=catalog/product&user_token=xxx
using latest opencart from the github Version 4.0.2.4

i can edit some other products tough it ahppens only with some

here is first 20 lines off attribute.php:

Code: Select all

<?php
namespace Opencart\Admin\Model\Catalog;
/*
 * Class Attribute
 *
 * Can be called from $this->load->model('catalog/attribute');
 *
 * @package Opencart\Admin\Model\Catalog
 * */
class Attribute extends \Opencart\System\Engine\Model {
	/*
	 *	Add Attribute
	 *
	 *	Create a new attribute record in the database.
	 *
     *	@param	array	$data
	 *
	 *	@return	int		returns the primary key of the new attribute record.
	 */
	/**

Active Member

Posts

Joined
Mon Jan 23, 2023 10:39 pm

Post by xxvirusxx » Mon Feb 12, 2024 4:21 pm

What ocmod extension you use?

Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by ravikumar22 » Mon Feb 12, 2024 8:15 pm

Hourglasss wrote:
Mon Feb 12, 2024 11:26 am
GEtting a php error and blank page when trying to edit an product

Code: Select all

PHP Fatal error:  Cannot declare class Opencart\\Admin\\Model\\Catalog\\Attribute, because the name is already in use in /var/www/html/opencart/extension/ocmod/admin/model/catalog/attribute.php on line 10, referer: https://www.xx.com/xx/index.php?route=catalog/product&user_token=xxx
using latest opencart from the github Version 4.0.2.4

i can edit some other products tough it ahppens only with some

here is first 20 lines off attribute.php:

Code: Select all

<?php
namespace Opencart\Admin\Model\Catalog;
/*
 * Class Attribute
 *
 * Can be called from $this->load->model('catalog/attribute');
 *
 * @package Opencart\Admin\Model\Catalog
 * */
class Attribute extends \Opencart\System\Engine\Model {
	/*
	 *	Add Attribute
	 *
	 *	Create a new attribute record in the database.
	 *
     *	@param	array	$data
	 *
	 *	@return	int		returns the primary key of the new attribute record.
	 */
	/**
The error is thrown because of the use duplicate classes. Make sure. your extension or module is not being collapse.
If you still facing any issue let me know.

Image
:) :D :( :o OpenCart Support | Please email at: devinlabsolutions@gmail.com :drunk: :laugh: :)


User avatar
New member

Posts

Joined
Sun Apr 12, 2015 6:33 am

Post by paulfeakins » Mon Feb 12, 2024 9:06 pm

Hourglasss wrote:
Mon Feb 12, 2024 11:26 am
using latest opencart from the github Version 4.0.2.4
At this point, it's still probably best to use 3.0.3.9.

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Guru Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by Hourglasss » Mon Feb 12, 2024 11:29 pm

xxvirusxx wrote:
Mon Feb 12, 2024 4:21 pm
What ocmod extension you use?
ravikumar22 wrote:
Mon Feb 12, 2024 8:15 pm
Hourglasss wrote:
Mon Feb 12, 2024 11:26 am
GEtting a php error and blank page when trying to edit an product

Code: Select all

PHP Fatal error:  Cannot declare class Opencart\\Admin\\Model\\Catalog\\Attribute, because the name is already in use in /var/www/html/opencart/extension/ocmod/admin/model/catalog/attribute.php on line 10, referer: https://www.xx.com/xx/index.php?route=catalog/product&user_token=xxx
using latest opencart from the github Version 4.0.2.4

i can edit some other products tough it ahppens only with some

here is first 20 lines off attribute.php:

Code: Select all

<?php
namespace Opencart\Admin\Model\Catalog;
/*
 * Class Attribute
 *
 * Can be called from $this->load->model('catalog/attribute');
 *
 * @package Opencart\Admin\Model\Catalog
 * */
class Attribute extends \Opencart\System\Engine\Model {
	/*
	 *	Add Attribute
	 *
	 *	Create a new attribute record in the database.
	 *
     *	@param	array	$data
	 *
	 *	@return	int		returns the primary key of the new attribute record.
	 */
	/**
The error is thrown because of the use duplicate classes. Make sure. your extension or module is not being collapse.
If you still facing any issue let me know.

Im prety sure i dont use any ocmod extension since the support just got added recently it might just be cause it got added recently that its not setup properly yet?

i tried disabling all extensions to see and it still occurs

Active Member

Posts

Joined
Mon Jan 23, 2023 10:39 pm

Post by xxvirusxx » Mon Feb 12, 2024 11:31 pm

You have installed something.....
opencart/extension/ocmod/admin/model/catalog/attribute.php on line 10

On clean install doesn't exist
https://github.com/opencart/opencart/tr ... sion/ocmod

Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by JNeuhoff » Tue Feb 13, 2024 12:59 am

paulfeakins wrote:
Mon Feb 12, 2024 9:06 pm
Hourglasss wrote:
Mon Feb 12, 2024 11:26 am
using latest opencart from the github Version 4.0.2.4
At this point, it's still probably best to use 3.0.3.9.
Agree! OpenCart 4 is still subject to a lot of development.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by Hourglasss » Tue Feb 13, 2024 1:13 pm

xxvirusxx wrote:
Mon Feb 12, 2024 11:31 pm
You have installed something.....
opencart/extension/ocmod/admin/model/catalog/attribute.php on line 10

On clean install doesn't exist
https://github.com/opencart/opencart/tr ... sion/ocmod
it literly hadd folders with only attribute.phps i deleted all of them and and its working now ,
not sure for wich extension it was tough

the ocmod had this in it
Image

the index.html is empty and there is an template file in ocmod/syste/library/template containingi this :

Code: Select all

<?php
namespace Opencart\System\Library\Template;
/**
 * Class Template
 *
 * @package Opencart\System\Library\Template
 */
class Template {
	protected string $directory = '';
	protected array $path = [];

	/**
	 * addPath
	 *
	 * @param    string  $namespace
	 * @param    string  $directory
	 *
	 * @return	 void
	 */
	public function addPath(string $namespace, string $directory = ''): void {
		if (!$directory) {
			$this->directory = $namespace;
		} else {
			$this->path[$namespace] = $directory;
		}
	}

	/**
	 * Render
	 *
	 * @param	string	$filename
	 * @param	array	$data
	 * @param	string	$code
	 *
	 * @return	string
	 */
	public function render(string $filename, array $data = [], string $code = ''): string {
		if (!$code) {
			$file = $this->directory . $filename . '.tpl';

			$namespace = '';

			$parts = explode('/', $filename);

			foreach ($parts as $part) {
				if (!$namespace) {
					$namespace .= $part;
				} else {
					$namespace .= '/' . $part;
				}

				if (isset($this->path[$namespace])) {
					$file = $this->path[$namespace] . substr($filename, strlen($namespace) + 1) . '.tpl';
				}
			}

			if (isset($file) && is_file($file)) {
				$code = file_get_contents($file);
			} else {
				throw new \Exception('Error: Could not load template ' . $filename . '!');
			}
		}

		if ($code) {
			ob_start();

			extract($data);

			include(modification($this->compile($filename, $code)));

			return ob_get_clean();
		} else {
			return '';
		}
	}

	/**
	 * Compile
	 *
	 * @param	string	$filename
	 * @param	string	$code
	 *
	 * @return	string
	 */
	protected function compile(string $filename, string $code): string {
		$file = DIR_CACHE . 'template/' . hash('md5', $filename . $code) . '.php';

		if (!is_file($file)) {
			file_put_contents($file, $code, LOCK_EX);
		}

		return $file;
	}
}

Active Member

Posts

Joined
Mon Jan 23, 2023 10:39 pm

Post by ravikumar22 » Tue Feb 13, 2024 8:10 pm

Hourglasss wrote:
Tue Feb 13, 2024 1:13 pm
xxvirusxx wrote:
Mon Feb 12, 2024 11:31 pm
You have installed something.....
opencart/extension/ocmod/admin/model/catalog/attribute.php on line 10

On clean install doesn't exist
https://github.com/opencart/opencart/tr ... sion/ocmod
it literly hadd folders with only attribute.phps i deleted all of them and and its working now ,
not sure for wich extension it was tough

the ocmod had this in it
Image

the index.html is empty and there is an template file in ocmod/syste/library/template containingi this :

Code: Select all

<?php
namespace Opencart\System\Library\Template;
/**
 * Class Template
 *
 * @package Opencart\System\Library\Template
 */
class Template {
	protected string $directory = '';
	protected array $path = [];

	/**
	 * addPath
	 *
	 * @param    string  $namespace
	 * @param    string  $directory
	 *
	 * @return	 void
	 */
	public function addPath(string $namespace, string $directory = ''): void {
		if (!$directory) {
			$this->directory = $namespace;
		} else {
			$this->path[$namespace] = $directory;
		}
	}

	/**
	 * Render
	 *
	 * @param	string	$filename
	 * @param	array	$data
	 * @param	string	$code
	 *
	 * @return	string
	 */
	public function render(string $filename, array $data = [], string $code = ''): string {
		if (!$code) {
			$file = $this->directory . $filename . '.tpl';

			$namespace = '';

			$parts = explode('/', $filename);

			foreach ($parts as $part) {
				if (!$namespace) {
					$namespace .= $part;
				} else {
					$namespace .= '/' . $part;
				}

				if (isset($this->path[$namespace])) {
					$file = $this->path[$namespace] . substr($filename, strlen($namespace) + 1) . '.tpl';
				}
			}

			if (isset($file) && is_file($file)) {
				$code = file_get_contents($file);
			} else {
				throw new \Exception('Error: Could not load template ' . $filename . '!');
			}
		}

		if ($code) {
			ob_start();

			extract($data);

			include(modification($this->compile($filename, $code)));

			return ob_get_clean();
		} else {
			return '';
		}
	}

	/**
	 * Compile
	 *
	 * @param	string	$filename
	 * @param	string	$code
	 *
	 * @return	string
	 */
	protected function compile(string $filename, string $code): string {
		$file = DIR_CACHE . 'template/' . hash('md5', $filename . $code) . '.php';

		if (!is_file($file)) {
			file_put_contents($file, $code, LOCK_EX);
		}

		return $file;
	}
}
you can compare with fresh opencart files and your folder files. you can easily find the issue.

Image
:) :D :( :o OpenCart Support | Please email at: devinlabsolutions@gmail.com :drunk: :laugh: :)


User avatar
New member

Posts

Joined
Sun Apr 12, 2015 6:33 am

Post by JNeuhoff » Tue Feb 13, 2024 8:25 pm

And so it begins again, a new cycle of poor quality OCmod based extensions now on OpenCart 4, too :)

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by paulfeakins » Wed Feb 14, 2024 7:43 pm

JNeuhoff wrote:
Tue Feb 13, 2024 8:25 pm
And so it begins again, a new cycle of poor quality OCmod based extensions now on OpenCart 4, too :)
That's your opinion, to which you are entitled.

However, I would say Event-based extensions are obfuscated and inflexible.

The majority of OC developers agree with me.

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Guru Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom
Who is online

Users browsing this forum: No registered users and 2 guests