Skip to content

Commit

Permalink
Fixed conflict between hidden product characteristics and download su…
Browse files Browse the repository at this point in the history
…b-panel
  • Loading branch information
aimeos committed Apr 16, 2018
1 parent afe1063 commit 0832771
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 66 deletions.
71 changes: 6 additions & 65 deletions admin/jqadm/src/Admin/JQAdm/Product/Download/Standard.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,17 +314,13 @@ protected function cleanupItems( array $listItems, array $listIds )

foreach( $rmListIds as $idx => $rmListId )
{
if( ( $item = $listItems[$rmListId]->getRefItem() ) !== null && $item->getType() === 'download' )
if( ( $item = $listItems[$rmListId]->getRefItem() ) !== null )
{
if( $item->getCode() != '' && $fs->has( $item->getCode() ) ) {
$fs->rm( $item->getCode() );
}
$rmItems[] = $item->getId();
}
else
{
unset( $rmListIds[$idx] );
}
}

$listManager->deleteItems( $rmListIds );
Expand Down Expand Up @@ -374,59 +370,6 @@ protected function createListItem( $id )
}


/**
* Returns the attribute items for the given list items
*
* @param array $listItems List of list items with IDs as key and items implementing \Aimeos\MShop\Common\Item\List\Iface as values
* @return array List of attribute items with ID as key and items implementing \Aimeos\MShop\Attribute\Item\Iface as values
*/
protected function getAttributeItems( array $listItems )
{
$refIds = [];

foreach( $listItems as $item ) {
$refIds[] = $item->getRefId();
}

$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' );

$search = $manager->createSearch();
$expr = array(
$search->compare( '==', 'attribute.id', $refIds ),
$search->compare( '==', 'attribute.domain', 'product' ),
$search->compare( '==', 'attribute.type.domain', 'product' ),
$search->compare( '==', 'attribute.type.code', 'download' ),
);
$search->setConditions( $search->combine( '&&', $expr ) );
$search->setSlice( 0, 0x7fffffff );

return $manager->searchItems( $search );
}


/**
* Returns the referenced products for the given product ID
*
* @param string $prodid Unique product ID
* @return array Associative list of bundle product IDs as keys and list items as values
*/
protected function getListItems( $prodid )
{
$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/lists' );

$search = $manager->createSearch();
$expr = array(
$search->compare( '==', 'product.lists.parentid', $prodid ),
$search->compare( '==', 'product.lists.domain', 'attribute' ),
$search->compare( '==', 'product.lists.type.domain', 'attribute' ),
$search->compare( '==', 'product.lists.type.code', 'hidden' ),
);
$search->setConditions( $search->combine( '&&', $expr ) );

return $manager->searchItems( $search );
}


/**
* Returns the list of sub-client names configured for the client.
*
Expand Down Expand Up @@ -479,7 +422,7 @@ protected function fromArray( \Aimeos\MShop\Product\Item\Iface $item, array $dat
$listManager = \Aimeos\MShop\Factory::createManager( $context, 'product/lists' );

$listId = $this->getValue( $data, 'product.lists.id' );
$listItems = $this->getListItems( $item->getId() );
$listItems = $item->getListItems( 'attribute', 'hidden', 'download', false );

if( isset( $listItems[$listId] ) ) {
$litem = $listItems[$listId];
Expand Down Expand Up @@ -525,9 +468,7 @@ protected function fromArray( \Aimeos\MShop\Product\Item\Iface $item, array $dat
*/
protected function toArray( \Aimeos\MShop\Product\Item\Iface $item, $copy = false )
{
$listItems = $this->getListItems( $item->getId() );
$attrItems = $this->getAttributeItems( $listItems );

$listItems = $item->getListItems( 'attribute', 'hidden', 'download', false );
$siteId = $this->getContext()->getLocale()->getSiteId();
$data = [];

Expand All @@ -537,7 +478,7 @@ protected function toArray( \Aimeos\MShop\Product\Item\Iface $item, $copy = fals

foreach( $listItems as $listItem )
{
if( !isset( $attrItems[$listItem->getRefId()] ) ) {
if( ( $refItem = $listItem->getRefItem() ) === null ) {
continue;
}

Expand All @@ -551,11 +492,11 @@ protected function toArray( \Aimeos\MShop\Product\Item\Iface $item, $copy = fals
$data[$key] = $value;
}

foreach( $attrItems[$listItem->getRefId()]->toArray( true ) as $key => $value ) {
foreach( $refItem->toArray( true ) as $key => $value ) {
$data[$key] = $value;
}

$data['path'] = $attrItems[$listItem->getRefId()]->getCode();
$data['path'] = $refItem->getCode();

try
{
Expand Down
2 changes: 1 addition & 1 deletion admin/jqadm/src/Admin/JQAdm/Product/Standard.php
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ protected function fromArray( array $data )

$item = $manager->saveItem( $item );

return $manager->getItem( $item->getId() ); // product.type must be available;
return $manager->getItem( $item->getId(), $this->getDomains() ); // product.type and list/ref items must be available
}


Expand Down

0 comments on commit 0832771

Please sign in to comment.