public function delete(IItem $objItem)
{
$arrIds = array($objItem->get('id'));
// Determine if the model is a variant base and if so, fetch the variants additionally.
if ($objItem->isVariantBase()) {
$objVariants = $objItem->getVariants(new Filter($this));
foreach ($objVariants as $objVariant) {
/** @var IItem $objVariant */
$arrIds[] = $objVariant->get('id');
}
}
// Complex attributes shall delete their values first.
foreach ($this->getAttributes() as $objAttribute) {
if ($this->isComplexAttribute($objAttribute)) {
/** @var IComplex $objAttribute */
$objAttribute->unsetDataFor($arrIds);
}
}
// Now make the real row disappear.
$this->getDatabase()->prepare(sprintf('DELETE FROM %s WHERE id IN (%s)', $this->getTableName(), $this->buildDatabaseParameterList($arrIds)))->execute($arrIds);
}