Product decorator did not work
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
- IvanIgniter
- Posts: 58
- Joined: 01 Dec 2021, 07:41
Product decorator did not work
Can you please help in my code to work with product decorator which will display the 'barcode' column from product table which was added after I extend in ext\ai-laravel\lib\custom\setup\default\schema\product.php. I was working fine in the database after I run php artisan aimeos:setup.
I would like to display the value of the product.barcode column in the product edit page based on
https://aimeos.org/docs/2021.x/models/e ... -decorator I have made \ext\ai-laravel\lib\custom\src\MShop\Product\Manager\Decorator\Myproject.php
\ext\ai-laravel\config\mshop.php
I tried to display the value of barcode in \ext\ai-admin-jqadm\admin\jqadm\src\Admin\JQAdm\Product\Standard.php
but it just display the default value because it returns null value.
Or in
\ext\ai-admin-jqadm\admin\jqadm\templates\product\item-standard.php would still return a null value.
I have follow the instruction from the documentation in https://aimeos.org/docs/latest/models/extend-managers/
but I have no luck. Please instruct how to make it work correctly?
Note: I am using laravel 6.x, PHP 7.4, Docker desktop/Ubuntu and the Aimeos 2021 - https://github.com/aimeos/aimeos-laravel
I would like to display the value of the product.barcode column in the product edit page based on
https://aimeos.org/docs/2021.x/models/e ... -decorator I have made \ext\ai-laravel\lib\custom\src\MShop\Product\Manager\Decorator\Myproject.php
Code: Select all
<?php
namespace Aimeos\MShop\Product\Manager\Decorator;
class Myproject extends \Aimeos\MShop\Common\Manager\Decorator\Base
{
private $attr = [
'barcode' => [
'code' => 'barcode',
'internalcode' => 'mpro."barcode"',
'label' => 'Barcode',
'type' => 'string',
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,
],
];
public function getSaveAttributes() : array
{
return parent::getSaveAttributes() + $this->createAttributes( $this->attr );
}
public function getSearchAttributes( bool $sub = true ) : array
{
return parent::getSearchAttributes( $sub ) + $this->createAttributes( $this->attr );
}
}
Code: Select all
<?php
return [
'product' => [
'manager' => [
'decorators' => [
'local' => ['Myproject']
]
]
]
];
but it just display the default value because it returns null value.
Code: Select all
public function get() : ?string
{
$view = $this->getObject()->addData( $this->getView() );
try
{
if( ( $id = $view->param( 'id' ) ) === null )
{
$msg = $this->getContext()->translate( 'admin', 'Required parameter "%1$s" is missing' );
throw new \Aimeos\Admin\JQAdm\Exception( sprintf( $msg, 'id' ) );
}
$manager = \Aimeos\MShop::create( $this->getContext(), 'product' );
$view->item = $manager->get( $id, $this->getDomains() );
dd($view->item->get( 'barcode', '<default value1>' ));
dd($view->item->get( 'product.barcode', '<default value2>' ));
dd($view->item->get( 'mpro.barcode', '<default value3>' ));
$view->itemData = $this->toArray( $view->item );
$view->itemBody = parent::get();
}
catch( \Exception $e )
{
$this->report( $e, 'get' );
}
return $this->render( $view );
}
\ext\ai-admin-jqadm\admin\jqadm\templates\product\item-standard.php would still return a null value.
Code: Select all
$enc->attr( $this->get( 'barcode' ) )
but I have no luck. Please instruct how to make it work correctly?
Note: I am using laravel 6.x, PHP 7.4, Docker desktop/Ubuntu and the Aimeos 2021 - https://github.com/aimeos/aimeos-laravel
- IvanIgniter
- Posts: 58
- Joined: 01 Dec 2021, 07:41
Re: Product decorator did not work
I have figure it out.
It should have be in \ext\ai-admin-jqadm\lib\custom\src\MShop\Product\Manager\Decorator\Myproject.php
Thank you
It should have be in \ext\ai-admin-jqadm\lib\custom\src\MShop\Product\Manager\Decorator\Myproject.php
Thank you