source/Application/Model/Category.php
public function delete($sOXID = null)
    {
        if (!$this->getId()) {
            $this->load($sOXID);
        }

        $sOXID = isset($sOXID) ? $sOXID : $this->getId();

        $myConfig = \OxidEsales\Eshop\Core\Registry::getConfig();
        $oDb = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();
        $blRet = false;

        if ($this->oxcategories__oxright->value == ($this->oxcategories__oxleft->value + 1)) {
            $myUtilsPic = \OxidEsales\Eshop\Core\Registry::getUtilsPic();
            $sDir = $myConfig->getPictureDir(false);

            // only delete empty categories
            // #1173M - not all pic are deleted, after article is removed
            $myUtilsPic->safePictureDelete($this->oxcategories__oxthumb->value, $sDir . \OxidEsales\Eshop\Core\Registry::getUtilsFile()->getImageDirByType('TC'), 'oxcategories', 'oxthumb');
            $myUtilsPic->safePictureDelete($this->oxcategories__oxicon->value, $sDir . \OxidEsales\Eshop\Core\Registry::getUtilsFile()->getImageDirByType('CICO'), 'oxcategories', 'oxicon');
            $myUtilsPic->safePictureDelete($this->oxcategories__oxpromoicon->value, $sDir . \OxidEsales\Eshop\Core\Registry::getUtilsFile()->getImageDirByType('PICO'), 'oxcategories', 'oxpromoicon');

            $sAdd = " and oxshopid = '" . $this->getShopId() . "' ";

            $oDb->execute(
                "UPDATE oxcategories SET OXLEFT = OXLEFT - 2
                                           WHERE  OXROOTID = " . $oDb->quote($this->oxcategories__oxrootid->value) . "
                            AND OXLEFT >   " . ((int) $this->oxcategories__oxleft->value) . $sAdd
            );

            $oDb->execute(
                "UPDATE oxcategories SET OXRIGHT = OXRIGHT - 2
                                           WHERE  OXROOTID = " . $oDb->quote($this->oxcategories__oxrootid->value) . "
                            AND OXRIGHT >   " . ((int) $this->oxcategories__oxright->value) . $sAdd
            );

            // delete entry
            $blRet = parent::delete($sOXID);

            $sOxidQuoted = $oDb->quote($sOXID);
            // delete links to articles
            $oDb->execute("delete from oxobject2category where oxobject2category.oxcatnid=$sOxidQuoted ");

            // #657 ADDITIONAL delete links to attributes
            $oDb->execute("delete from oxcategory2attribute where oxcategory2attribute.oxobjectid=$sOxidQuoted ");

            // A. removing assigned:
            // - deliveries
            $oDb->execute("delete from oxobject2delivery where oxobject2delivery.oxobjectid=$sOxidQuoted ");
            // - discounts
            $oDb->execute("delete from oxobject2discount where oxobject2discount.oxobjectid=$sOxidQuoted ");

            \OxidEsales\Eshop\Core\Registry::get(\OxidEsales\Eshop\Application\Model\SeoEncoderCategory::class)->onDeleteCategory($this);
        }

        return $blRet;
    }
public function delete($sOXID = null)
    {
        if (!$this->getId()) {
            $this->load($sOXID);
        }

        $sOXID = isset($sOXID) ? $sOXID : $this->getId();

        $myConfig = \OxidEsales\Eshop\Core\Registry::getConfig();
        $oDb = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();
        $blRet = false;

        if ($this->oxcategories__oxright->value == ($this->oxcategories__oxleft->value + 1)) {
            $myUtilsPic = \OxidEsales\Eshop\Core\Registry::getUtilsPic();
            $sDir = $myConfig->getPictureDir(false);

            // only delete empty categories
            // #1173M - not all pic are deleted, after article is removed
            $myUtilsPic->safePictureDelete($this->oxcategories__oxthumb->value, $sDir . \OxidEsales\Eshop\Core\Registry::getUtilsFile()->getImageDirByType('TC'), 'oxcategories', 'oxthumb');
            $myUtilsPic->safePictureDelete($this->oxcategories__oxicon->value, $sDir . \OxidEsales\Eshop\Core\Registry::getUtilsFile()->getImageDirByType('CICO'), 'oxcategories', 'oxicon');
            $myUtilsPic->safePictureDelete($this->oxcategories__oxpromoicon->value, $sDir . \OxidEsales\Eshop\Core\Registry::getUtilsFile()->getImageDirByType('PICO'), 'oxcategories', 'oxpromoicon');

            $sAdd = " and oxshopid = '" . $this->getShopId() . "' ";

            $oDb->execute(
                "UPDATE oxcategories SET OXLEFT = OXLEFT - 2
                                           WHERE  OXROOTID = " . $oDb->quote($this->oxcategories__oxrootid->value) . "
                            AND OXLEFT >   " . ((int) $this->oxcategories__oxleft->value) . $sAdd
            );

            $oDb->execute(
                "UPDATE oxcategories SET OXRIGHT = OXRIGHT - 2
                                           WHERE  OXROOTID = " . $oDb->quote($this->oxcategories__oxrootid->value) . "
                            AND OXRIGHT >   " . ((int) $this->oxcategories__oxright->value) . $sAdd
            );

            // delete entry
            $blRet = parent::delete($sOXID);

            $sOxidQuoted = $oDb->quote($sOXID);
            // delete links to articles
            $oDb->execute("delete from oxobject2category where oxobject2category.oxcatnid=$sOxidQuoted ");

            // #657 ADDITIONAL delete links to attributes
            $oDb->execute("delete from oxcategory2attribute where oxcategory2attribute.oxobjectid=$sOxidQuoted ");

            // A. removing assigned:
            // - deliveries
            $oDb->execute("delete from oxobject2delivery where oxobject2delivery.oxobjectid=$sOxidQuoted ");
            // - discounts
            $oDb->execute("delete from oxobject2discount where oxobject2discount.oxobjectid=$sOxidQuoted ");

            \OxidEsales\Eshop\Core\Registry::get(\OxidEsales\Eshop\Application\Model\SeoEncoderCategory::class)->onDeleteCategory($this);
        }

        return $blRet;
    }
public function delete ( $ sOXID = null ) { if ( ! $ this -> getId ( ) ) { $ this -> load ( $ sOXID ) ; } $ sOXID = isset ( $ sOXID ) ? $ sOXID : $ this -> getId ( ) ; $ myConfig = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) ; $ oDb = \ OxidEsales \ Eshop \ Core \ DatabaseProvider :: getDb ( ) ; $ blRet = false ; if ( $ this -> oxcategories__oxright -> value == ( $ this -> oxcategories__oxleft -> value + 1 ) ) { $ myUtilsPic = \ OxidEsales \ Eshop \ Core \ Registry :: getUtilsPic ( ) ; $ sDir = $ myConfig -> getPictureDir ( false ) ; // only delete empty categories // #1173M - not all pic are deleted, after article is removed $ myUtilsPic -> safePictureDelete ( $ this -> oxcategories__oxthumb -> value , $ sDir . \ OxidEsales \ Eshop \ Core \ Registry :: getUtilsFile ( ) -> getImageDirByType ( 'TC' ) , 'oxcategories' , 'oxthumb' ) ; $ myUtilsPic -> safePictureDelete ( $ this -> oxcategories__oxicon -> value , $ sDir . \ OxidEsales \ Eshop \ Core \ Registry :: getUtilsFile ( ) -> getImageDirByType ( 'CICO' ) , 'oxcategories' , 'oxicon' ) ; $ myUtilsPic -> safePictureDelete ( $ this -> oxcategories__oxpromoicon -> value , $ sDir . \ OxidEsales \ Eshop \ Core \ Registry :: getUtilsFile ( ) -> getImageDirByType ( 'PICO' ) , 'oxcategories' , 'oxpromoicon' ) ; $ sAdd = " and oxshopid = '" . $ this -> getShopId ( ) . "' " ; $ oDb -> execute ( "UPDATE oxcategories SET OXLEFT = OXLEFT - 2
                                           WHERE  OXROOTID = " . $ oDb -> quote ( $ this -> oxcategories__oxrootid -> value ) . "
                            AND OXLEFT >   " . ( ( int ) $ this -> oxcategories__oxleft -> value ) . $ sAdd ) ; $ oDb -> execute ( "UPDATE oxcategories SET OXRIGHT = OXRIGHT - 2
                                           WHERE  OXROOTID = " . $ oDb -> quote ( $ this -> oxcategories__oxrootid -> value ) . "
                            AND OXRIGHT >   " . ( ( int ) $ this -> oxcategories__oxright -> value ) . $ sAdd ) ; // delete entry $ blRet = parent :: delete ( $ sOXID ) ; $ sOxidQuoted = $ oDb -> quote ( $ sOXID ) ; // delete links to articles $ oDb -> execute ( "delete from oxobject2category where oxobject2category.oxcatnid=$sOxidQuoted " ) ; // #657 ADDITIONAL delete links to attributes $ oDb -> execute ( "delete from oxcategory2attribute where oxcategory2attribute.oxobjectid=$sOxidQuoted " ) ; // A. removing assigned: // - deliveries $ oDb -> execute ( "delete from oxobject2delivery where oxobject2delivery.oxobjectid=$sOxidQuoted " ) ; // - discounts $ oDb -> execute ( "delete from oxobject2discount where oxobject2discount.oxobjectid=$sOxidQuoted " ) ; \ OxidEsales \ Eshop \ Core \ Registry :: get ( \ OxidEsales \ Eshop \ Application \ Model \ SeoEncoderCategory :: class ) -> onDeleteCategory ( $ this ) ; } return $ blRet ; }
Delete empty categories, returns true on success.

@param string $sOXID Object ID

@return bool
Delete empty categories returns true on success .