Getting physical properties in decorator
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
-
- Posts: 41
- Joined: 03 Jun 2023, 17:30
Getting physical properties in decorator
Hello,
Laravel Framework 10.13.1, php8.1-fpm, aimeos/aimeos-laravel 2023.04.2
In the Admin I setup physical properties for length, width, height, weight on each product. I want to use these in my FedEx decorators calcPrice() method to generate an accurate shipping quote.
Below is how I am currently looping through the products in the cart and generating line items for the shipping quote. Is this optimal? I want to ensure that I am not taking the long route and doing too much unnecessary fetching and data massaging jus to get these product properties:
Laravel Framework 10.13.1, php8.1-fpm, aimeos/aimeos-laravel 2023.04.2
In the Admin I setup physical properties for length, width, height, weight on each product. I want to use these in my FedEx decorators calcPrice() method to generate an accurate shipping quote.
Below is how I am currently looping through the products in the cart and generating line items for the shipping quote. Is this optimal? I want to ensure that I am not taking the long route and doing too much unnecessary fetching and data massaging jus to get these product properties:
Code: Select all
$ids = $basket->getProducts()->getProductId();
$manager = \Aimeos\MShop::create($this->context(), 'product');
$filter = $manager->filter(true);
$filter->add('product.id', '==', $ids->toArray());
$items = $manager->search($filter, ['product/property']);
$item_properties = $items->getPropertyItems();
$properties = [];
foreach( $basket->getProducts() as $orderProduct ) {
$order_items = $item_properties->get( $orderProduct->getProductId(), [] )->toArray();
foreach ($order_items as $order_item) {
$properties[$order_item->getType()] = $order_item->getValue();
}
$FedEx->addNewLineItem()
->weight = $properties['package-weight']
->length = $properties['package-length']
->width = $properties['package-width']
->height = $properties['package-height']
}
Re: Getting physical properties in decorator
There's a more efficient way: Use the PropertyAdd plugin to add those properties to the products in the basket automatically:
https://aimeos.org/docs/latest/manual/p ... ropertyadd
https://aimeos.org/docs/latest/manual/p ... ropertyadd
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
-
- Posts: 41
- Joined: 03 Jun 2023, 17:30
Re: Getting physical properties in decorator
Thank you,
In Admin > Setup > Plugins I didnt see an existing entry for the PropertyAdd plugin listed. I clicked the button to add a new entry and selected 'PropertyAdd' as the provider. The 'types' option automatically appears, but I am not able to insert a value. Initially the input box does not even appear for the value. I can add a new option, called it 'types' and input the JSON array, but once I hit save the input box is cleared again and doesnt display after page reload..
In Admin > Setup > Plugins I didnt see an existing entry for the PropertyAdd plugin listed. I clicked the button to add a new entry and selected 'PropertyAdd' as the provider. The 'types' option automatically appears, but I am not able to insert a value. Initially the input box does not even appear for the value. I can add a new option, called it 'types' and input the JSON array, but once I hit save the input box is cleared again and doesnt display after page reload..
-
- Posts: 41
- Joined: 03 Jun 2023, 17:30
Re: Getting physical properties in decorator
Maybe the issue with the value input field not showing is a 'me' problem with my install?
For different decorator that I have, I tried to switch my beConfig to a 'select' and the select drop down never appears:
In the admin interface the browsers web developer tools show this for both the AddProperty value and my select dropdown value:
For different decorator that I have, I tried to switch my beConfig to a 'select' and the select drop down never appears:
Code: Select all
private array $beConfig = array(
'servicetype' => array(
'code' => 'servicetype',
'internalcode' => 'servicetype',
'label' => 'FedEx service delivery type.',
'type' => 'select',
'internaltype' => 'string',
'default' => [
'GROUND_HOME_DELIVERY' => 'GROUND_HOME_DELIVERY',
'FEDEX_GROUND' => 'FEDEX_GROUND',
'FEDEX_2_DAY' => 'FEDEX_2_DAY',
'PRIORITY_OVERNIGHT' => 'PRIORITY_OVERNIGHT',
'FIRST_OVERNIGHT' => 'FIRST_OVERNIGHT',
],
'required' => true,
),
);
Code: Select all
<td class="config-row-value"><!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----></td>
Re: Getting physical properties in decorator
Sorry, the "list" type hadn't been implemented in the new config table code. This is fixed now and you can get the new aimeos/ai-admin-jqadm package by executing "composer up".
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
-
- Posts: 41
- Joined: 03 Jun 2023, 17:30
Re: Getting physical properties in decorator
Thank you, that fixed the issue with the PropertyAdd config value.