Using Aimeos\MShop\Product\Item\Standard in a custom EXT
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!
Always add your TYPO3, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Using Aimeos\MShop\Product\Item\Standard in a custom EXT
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:
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
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;
}
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
Re: Using Aimeos\MShop\Product\Item\Standard in a custom EXT
Can you share your class implementation for testing?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
Re: Using Aimeos\MShop\Product\Item\Standard in a custom EXT
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:
Manager:
Required configuration:
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
Item:
Code: Select all
<?php
namespace Aimeos\MShop\Product\Item;
class Test
extends \Aimeos\MShop\Product\Item\Standard
{
}
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 );
}
}
Code: Select all
<?php
return [
'product' => [
'manager' => [
'name' => 'Test',
]
]
];
- 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, give us a star
If you like Aimeos, give us a star