Skip to content

Commit

Permalink
Removes catalog references if a product is deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
aimeos committed Jan 16, 2017
1 parent e4b313e commit a742acd
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions admin/jqadm/src/Admin/JQAdm/Product/Category/Standard.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,42 @@ public function create()
}


/**
* Deletes a resource
*
* @return string|null admin output to display or null for redirecting to the list
*/
public function delete()
{
$view = $this->getView();
$context = $this->getContext();

$manager = \Aimeos\MShop\Factory::createManager( $context, 'catalog/lists' );

$search = $manager->createSearch();
$expr = array(
$search->compare( '==', 'catalog.lists.refid', $view->param( 'id' ) ),
$search->compare( '==', 'catalog.lists.domain', 'product' )
);
$search->setConditions( $search->combine( '&&', $expr ) );
$search->setSortations( array( $search->sort( '+', 'catalog.lists.id' ) ) );

$start = 0;

do
{
$search->setSlice( $start );

$result = $manager->searchItems( $search );
$manager->deleteItems( array_keys( $result ) );

$count = count( $result );
$start += $count;
}
while( $count >= $search->getSliceSize() );
}


/**
* Returns a single resource
*
Expand Down

0 comments on commit a742acd

Please sign in to comment.