Add column to mshop_order_base
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!
Add column to mshop_order_base
Hi, I want to add a column to the table mshop_order_base.
I followed the guide from https://aimeos.org/docs/Developers/Libr ... gers_items creating a decorator but I'm unable to retrieve this field in the manager.
With the table mshop_order I done the same and it works without problems in its relative manager.
Which are the differences of extending a table of a item and a subitem?
Thank you.
I followed the guide from https://aimeos.org/docs/Developers/Libr ... gers_items creating a decorator but I'm unable to retrieve this field in the manager.
With the table mshop_order I done the same and it works without problems in its relative manager.
Which are the differences of extending a table of a item and a subitem?
Thank you.
Re: Add column to mshop_order_base
Make sure you use the right configuration, e.g. "mshop/order/manager/base/decorator/local" with "['Mydecorator']" to wrap a local decorator ("local" means it uses the same namespace as the manager you want do decorate + "\Decorator") around the order base manager.
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: Add column to mshop_order_base
Now I tried to decorate mshop_order_base_product and I have the same problem.
This is ext/vg7/config/mshop.php:
and this is the decorator in ext/vg7/lib/custom/src/MShop/Order/Manager/Base/Product/Decorator/OrderBaseProductIdPrint.php:
This is ext/vg7/config/mshop.php:
Code: Select all
<?php
return [
'order' => [
'manager' => [
'name' => 'OrderVG7',
'decorators' => [
'local' => ['OrderIdPrint']
],
'base' => [
'name' => 'OrderBaseVG7',
'address' => [
'name' => 'OrderBaseAddressVG7'
],
'product' => [
'name' => 'OrderBaseProductVG7',
'decorators' => [
'local' => ['OrderBaseProductIdPrint']
]
]
]
],
'item' => [
'name' => 'OrderVG7',
'base' => [
'name' => 'OrderBaseVG7',
'address' => [
'name' => 'OrderBaseAddressVG7'
],
'product' => [
'name' => 'OrderBaseProductVG7'
]
]
]
],
];
Code: Select all
<?php
namespace Aimeos\MShop\Order\Manager\Base\Product\Decorator;
class OrderBaseProductIdPrint extends \Aimeos\MShop\Common\Manager\Decorator\Base
{
private $attr = [
'id_print' => [
'code' => 'id_print',
'internalcode' => 'mordbapr."id_print"',
'type' => 'integer',
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_INT,
],
];
public function getSaveAttributes()
{
return parent::getSaveAttributes() + $this->createAttributes( $this->attr );
}
public function getSearchAttributes( $sub = true )
{
return parent::getSearchAttributes( $sub ) + $this->createAttributes( $this->attr );
}
}
Re: Add column to mshop_order_base
Your code and configuration seems to be OK but the item configuration is useless and should be removed:
because the items must be instantiated by the createItemBase() method of your managers. With decorators, you can get/set the new properties with the generic get( 'name' ) and set( 'name', 'value' ) methods that are available in all items.
Code: Select all
'item' => [
'name' => 'OrderVG7',
'base' => [
'name' => 'OrderBaseVG7',
'address' => [
'name' => 'OrderBaseAddressVG7'
],
'product' => [
'name' => 'OrderBaseProductVG7'
]
]
]
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: Add column to mshop_order_base
Ok, I removed the item configuration, but the problem is still here.
I tried to investigate more accurately and I found that, for example in the method saveItem() of the manager of order/base/product, when executes $columns = $this->getObject()->getSaveAttributes(), $columns is empty because getObject() doesn't return the decorator but the manager itself.
I believe that there is a bug of populating $object with the decorator for order/base and its child, but I'm not able to investigate more further.
Can you please address me to the right way?
I also found that the "Custom Way" of this guide https://aimeos.org/docs/Developers/Libr ... gers_items it works so the problems are only with the decorator mode.
I tried to investigate more accurately and I found that, for example in the method saveItem() of the manager of order/base/product, when executes $columns = $this->getObject()->getSaveAttributes(), $columns is empty because getObject() doesn't return the decorator but the manager itself.
I believe that there is a bug of populating $object with the decorator for order/base and its child, but I'm not able to investigate more further.
Can you please address me to the right way?
I also found that the "Custom Way" of this guide https://aimeos.org/docs/Developers/Libr ... gers_items it works so the problems are only with the decorator mode.
Re: Add column to mshop_order_base
You haven't configured any decorator for the order base manager, only for the order base product manager according to your posted configuration. Thus, the array for the custom save attribute is empty.
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: Add column to mshop_order_base
Yes, now I want to decorate only order base product.
The getObject() method is referring of the order base product manager class, and with my configuration I expect that return the OrderBaseProductIdPrint decorator, but return the order base product manager itself.
The getObject() method is referring of the order base product manager class, and with my configuration I expect that return the OrderBaseProductIdPrint decorator, but return the order base product manager itself.
Re: Add column to mshop_order_base
Sorry, was looking at the wrong place.
We've made a change so decorators are now passed down to submanagers.
Can you update and confirm that it's working now?
We've made a change so decorators are now passed down to submanagers.
Can you update and confirm that it's working now?
Code: Select all
composer req aimeos/aimeos-core:2019.10.x-dev
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: Add column to mshop_order_base
Ok, now it works, thank you!