Skip to content

Commit

Permalink
Make physical product property types configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
aimeos committed Apr 17, 2021
1 parent 9384b62 commit 09f4dd8
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
Expand Up @@ -198,16 +198,11 @@ public function getSubClient( string $type, string $name = null ) : \Aimeos\Admi
*/
protected function excludeItems( \Aimeos\Map $propItems ) : \Aimeos\Map
{
$excludes = array( 'package-length', 'package-height', 'package-width', 'package-weight' );

foreach( $propItems as $key => $propItem )
{
if( in_array( $propItem->getType(), $excludes ) ) {
unset( $propItems[$key] );
}
}
$excludes = $this->getContext()->getConfig()->get( 'admin/jqadm/product/physical/types', [] );

return $propItems;
return $propItems->filter( function( $item ) use ( $excludes ) {
return !in_array( $item->getType(), $excludes );
} );
}


Expand Down
17 changes: 16 additions & 1 deletion admin/jqadm/src/Admin/JQAdm/Product/Physical/Standard.php
Expand Up @@ -280,7 +280,22 @@ protected function fromArray( \Aimeos\MShop\Product\Item\Iface $item, array $dat
protected function toArray( \Aimeos\MShop\Product\Item\Iface $item, bool $copy = false ) : array
{
$data = [];
$types = ['package-length', 'package-height', 'package-width', 'package-weight'];

/** admin/jqadm/product/physical/types
* Type codes used for physical product properties values
*
* Physical values like "package-length", "package-height", "package-width" and
* "package-weight" are stored as regular product properties. To avoid displaying
* them in the product characteristics tab too, these types are excluded there.
*
* You can add new physical types by adding additional type codes and insert the
* input fields for displaying and changing them in the product/item-physical-standard
* template.
*
* @param array List of product property type codes
* @since 2021.07
*/
$types = $this->getContext()->getConfig()->get( 'admin/jqadm/product/physical/types', [] );

foreach( $item->getPropertyItems( $types, false ) as $item ) {
$data[$item->getType()] = $item->getValue();
Expand Down
8 changes: 8 additions & 0 deletions config/admin/jqadm.php
Expand Up @@ -182,6 +182,14 @@
'bought' => 'bought',
],
],
'physical' => [
'types' => [
'package-length' => 'package-length',
'package-height' => 'package-height',
'package-width' => 'package-width',
'package-weight' => 'package-weight',
]
]
],
'product/category' => [
'decorators' => [
Expand Down

0 comments on commit 09f4dd8

Please sign in to comment.