To Add a new field to order ,below the invoice number
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!
To Add a new field to order ,below the invoice number
I'm new to Aimeos, and I'm using Aimeos 2023.07 with Laravel 9 and PHP 8. Could you please provide guidance on how to add a new field named 'priority' below the invoice number on the order details page within Aimeos' admin interface? Thank you in advance.
Re: To Add a new field to order ,below the invoice number
1.) Create you own extension here:
https://aimeos.org/extensions
2.) Create a database migration and a manager decorator to add the new field in your extension:
https://aimeos.org/docs/latest/models/extend-managers/
3.) Copy the order/item.php template to your extension and add your new field there:
https://aimeos.org/docs/latest/admin/jq ... templates/
https://aimeos.org/extensions
2.) Create a database migration and a manager decorator to add the new field in your extension:
https://aimeos.org/docs/latest/models/extend-managers/
3.) Copy the order/item.php template to your extension and add your new field there:
https://aimeos.org/docs/latest/admin/jq ... templates/
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: To Add a new field to order ,below the invoice number
Hi,
Thank you for your reply. I followed your instructions and added a new field to the mshop_order table. I also created and extended the manager and item files, and added code to the template folder. However, I am having trouble displaying, updating, and saving data in the new field. I am also having an issue with the macro definition for the get and set methods.
Please let me know if you have any suggestions.
Thank you for your reply. I followed your instructions and added a new field to the mshop_order table. I also created and extended the manager and item files, and added code to the template folder. However, I am having trouble displaying, updating, and saving data in the new field. I am also having an issue with the macro definition for the get and set methods.
Please let me know if you have any suggestions.
Re: To Add a new field to order ,below the invoice number
Add your new field in the template like this one but replace "order.relatedid" with "priority":
https://github.com/aimeos/ai-admin-jqad ... #L247-L259
The value of "priority" is automatically saved because it gets added to the item here:
https://github.com/aimeos/ai-admin-jqad ... d.php#L468
The manager will then save and fetch the value if the decorator is correctly implemented and configured (!)
https://github.com/aimeos/ai-admin-jqad ... #L247-L259
The value of "priority" is automatically saved because it gets added to the item here:
https://github.com/aimeos/ai-admin-jqad ... d.php#L468
The manager will then save and fetch the value if the decorator is correctly implemented and configured (!)
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: To Add a new field to order ,below the invoice number
The value of "priority" is automatically saved because it gets added to the item here:
https://github.com/aimeos/ai-admin-jqad ... d.php#L468
1)Don't know what I missed? I have added new field as per your instruction. Is the decorator created under the service anymore? Or is it enough to create under the manager directly?
https://github.com/aimeos/ai-admin-jqad ... d.php#L468
1)Don't know what I missed? I have added new field as per your instruction. Is the decorator created under the service anymore? Or is it enough to create under the manager directly?
Re: To Add a new field to order ,below the invoice number
Please show your code (diffs only, not full files)
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: To Add a new field to order ,below the invoice number
hi,
Added a field to mshop_order table in packages\myext-ext\setup\default\schema
Decorator file in \packages\myext-ext\src\MShop\Order\Manager\Decorator
And item file in packages\myext-ext\src\MShop\Order\Item
The template file is packages\myext-ext\templates\admin\jqadm\order
And the config is config/mshop.php
.
Thank you for your response.
Added a field to mshop_order table in packages\myext-ext\setup\default\schema
Code: Select all
'table' => array(
'mshop_order' => function ( \Aimeos\Upscheme\Schema\Table $table ) {
$table->engine = 'InnoDB';
//$table->addColumn( 'priority', 'string', array( 'length' => 64 ) );
$table->string( 'priority' );
return $table;
},
)
Code: Select all
namespace Aimeos\MShop\Order\Manager\Decorator;
class Myproject extends \Aimeos\MShop\Common\Manager\Decorator\Base
{
private $searchConfig = array(
'order.priority'=> array(
'code'=>'order.priority',
'internalcode'=>'mord."priority"',
'label'=>'order priority',
'type'=> 'string', // integer, float, etc.
'internaltype'=> \Aimeos\MW\DB\Statement\Base::PARAM_STR, // _INT, _FLOAT, etc.
),
);
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
/**
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
* @package MShop
* @subpackage Order
*/
namespace Aimeos\MShop\Order\Item;
class Myproject extends Standard
{
private $values;
public function __construct( array $values )
{
parent::__construct( 'order.', $values );
$this->values = $values;
}
/**
* Returns priority for the priority order
*
* @return string|null order priority of the order
*/
public function getPriority() : string
{
return (string) $this->get( 'order.priority','' ) ;
}
public function setPriority( ?string $value ) : \Aimeos\Mshop\Order\Item\Iface
{
return $this->set( 'order.priority', (string) $value );
}
$item = parent::fromArray( $list, $private );
foreach( $list as $key => $value )
{
switch( $key )
{
case 'order.priority': $item = $item->setPriority( $value ); break;
}
unset( $list[$key] );
}
dd($item);
return $item;
public function toArray( $private = false )
{
$list = parent::toArray( $private );
if( $private === true ) {
$list['order.priority'] = $this->getPriority();
}
dd($list);
return $list;
}
}
The template file is packages\myext-ext\templates\admin\jqadm\order
Code: Select all
div class="col-8">
<input class="form-control item-priority" type="text" tabindex="1"
name="<?= $enc->attr( $this->formparam( array( 'item', 'order.priority' ) ) ) ?>" placeholder="<?= $enc->attr( $this->translate( 'admin', 'Priority (optional)' ) ) ?>"
value="<?= $enc->attr( $this->get( 'itemData/priority' ) ) ?>"
:readonly="!can('change')">
</div>
Code: Select all
'order' => [
'manager' => [
'decorators' => [
'local' => ['Myproject']
]
],
'item' => [
'local' => ['Myproject']
],
],
Thank you for your response.
Re: To Add a new field to order ,below the invoice number
This is correct.archanaep wrote: ↑27 Oct 2023, 10:27Code: Select all
'table' => array( 'mshop_order' => function ( \Aimeos\Upscheme\Schema\Table $table ) { $table->string( 'priority' ); }, )
Here, the key and code is wrong because it must be "priority" only. In 2023.10+, you can strip the $searchConfig value down to:archanaep wrote: ↑27 Oct 2023, 10:27 Decorator file in \packages\myext-ext\src\MShop\Order\Manager\DecoratorCode: Select all
namespace Aimeos\MShop\Order\Manager\Decorator; class Myproject extends \Aimeos\MShop\Common\Manager\Decorator\Base { private $searchConfig = array( 'order.priority'=> array( 'code'=>'order.priority', 'internalcode'=>'mord."priority"', 'label'=>'order priority', 'type'=> 'string', // integer, float, etc. 'internaltype'=> \Aimeos\MW\DB\Statement\Base::PARAM_STR, // _INT, _FLOAT, etc. ), ); 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
'priority'=> array(
'internalcode'=>'mord."priority"',
'label'=>'order priority',
),
The order item class is unused and must be removed.
Here, it must be only "priority" too:archanaep wrote: ↑27 Oct 2023, 10:27 The template file is packages\myext-ext\templates\admin\jqadm\orderCode: Select all
div class="col-8"> <input class="form-control item-priority" type="text" tabindex="1" name="<?= $enc->attr( $this->formparam( array( 'item', 'order.priority' ) ) ) ?>" placeholder="<?= $enc->attr( $this->translate( 'admin', 'Priority (optional)' ) ) ?>" value="<?= $enc->attr( $this->get( 'itemData/priority' ) ) ?>" :readonly="!can('change')"> </div>
Code: Select all
name="<?= $enc->attr( $this->formparam( array( 'item', 'priority' ) ) ) ?>"
The "item" config is unused and must be removed.archanaep wrote: ↑27 Oct 2023, 10:27 And the config is config/mshop.php.Code: Select all
'order' => [ 'manager' => [ 'decorators' => [ 'local' => ['Myproject'] ] ], 'item' => [ 'local' => ['Myproject'] ], ],
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: To Add a new field to order ,below the invoice number
Thank you for your valuable reply. I modified the code in the template and decorator files, and the data now saves and updates successfully.
Re: To Add a new field to order ,below the invoice number
Hi,
I am getting error while editing catalog product from admin after adding new field in order section using Aimeos extension. Is there any mistake in adding only the desired folder like order inside Mshop and corresponding folder in JQAdm in the extension ?If so, what other files should be added? What should be done to access only the order folder from the extension folder and the rest of the from default folder?
The error is:
I am getting error while editing catalog product from admin after adding new field in order section using Aimeos extension. Is there any mistake in adding only the desired folder like order inside Mshop and corresponding folder in JQAdm in the extension ?If so, what other files should be added? What should be done to access only the order folder from the extension folder and the rest of the from default folder?
The error is:
Aimeos\MShop\Common\Item\Lists\Standard::setRefId(): Argument #1 ($refid) must be of type string, null given, called in /xx/xx/xx/xx/packages/myext-ext/src/Admin/JQAdm/Product/Category/Standard.php on line 250