Using Aimeos\MShop\Product\Item\Standard in a custom EXT

Questions around the TYPO3 integration and plugins
Forum rules
Always add your TYPO3, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Dennis
Posts: 15
Joined: 30 Nov 2016, 09:16

Using Aimeos\MShop\Product\Item\Standard in a custom EXT

Post by Dennis » 23 Nov 2017, 12:36

Hi,

in a custom extension I want to extend the core class Aimeos\MShop\Product\Item\Standard, but am getting the error 'PHP Fatal error: Class 'Aimeos\MShop\Product\Item\Standard' not found in ... (path of the custom php class)'.

The aimeos extension, where the class Aimeos\MShop\Product\Item\Standard is defined, is installed and activated, too.

Additionally I tried to build the extension with your extension builder described on https://aimeos.org/docs/Developers/Crea ... b.2Fcustom and https://aimeos.org/developer/extensions/, but am not getting rid of the error.

If I use something like this:

Code: Select all

$extPath = dirname(__DIR__, 6);
$localautoloader = $extPath . '/aimeos/Resources/Libraries/autoload.php';
if( file_exists( $localautoloader ) === true ) {
    require_once $localautoloader;
}
all classes are found and the error disappears.

However, I really think this is a suboptimal solution.

Could you explain a bit why exactly I get this error, why the core class is not found and what would be the best solution to extend the class Aimeos\MShop\Product\Item\Standard in a custom extension?

Thank you very much in advance again!


TYPO3 8.7.8. aimeos 17.10.1, PHP: 7.1.9, Operating system: Unix

User avatar
aimeos
Administrator
Posts: 7835
Joined: 01 Jan 1970, 00:00

Re: Using Aimeos\MShop\Product\Item\Standard in a custom EXT

Post by aimeos » 23 Nov 2017, 21:17

Can you share your class implementation for testing?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
aimeos
Administrator
Posts: 7835
Joined: 01 Jan 1970, 00:00

Re: Using Aimeos\MShop\Product\Item\Standard in a custom EXT

Post by aimeos » 27 Nov 2017, 12:25

We did a implementation of test classes to see if we get the same error but it works without problems and no additional autoloader is required. Here are the classes we've used:

Item:

Code: Select all

<?php

namespace Aimeos\MShop\Product\Item;

class Test
	extends \Aimeos\MShop\Product\Item\Standard
{
}
Manager:

Code: Select all

<?php

namespace Aimeos\MShop\Product\Manager;

class Test
	extends \Aimeos\MShop\Product\Manager\Standard
{
	protected function createItemBase( array $values = [], array $listItems = [],
		array $refItems = [], array $propertyItems = [] )
	{
		return new \Aimeos\MShop\Product\Item\Test( $values, $listItems, $refItems, $propertyItems );
	}
}
Required configuration:

Code: Select all

<?php

return [
	'product' => [
		'manager' => [
			'name' => 'Test',
		]
	]
];
All files have been placed in a generated 2017.x TYPO3 extension in
- Item: /typo3conf/ext/aitest/Resources/Private/Extensions/aitest/lib/custom/src/MShop/Product/Item/Test.php
- Manager: /typo3conf/ext/aitest/Resources/Private/Extensions/aitest/lib/custom/src/MShop/Product/Manager/Test.php
- Configuration: /typo3conf/ext/aitest/Resources/Private/Extensions/aitest/lib/custom/config/mshop.php
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply