public function cmdDeleteCollection()
    {
        $id = $this->getParam(0);
        $all = $this->getParam('all');

        if (empty($id) && empty($all)) {
            $this->errorAndExit($this->text('Invalid command'));
        }

        $options = null;

        if (isset($id)) {

            if ($this->getParam('type')) {
                $options = array('type' => $id);
            } else if ($this->getParam('store')) {

                if (!is_numeric($id)) {
                    $this->errorAndExit($this->text('Invalid argument'));
                }

                $options = array('store_id' => $id);
            }

        } else if (!empty($all)) {
            $options = array();
        }

        if (isset($options)) {

            $deleted = $count = 0;
            foreach ($this->collection->getList($options) as $item) {
                $count++;
                $deleted += (int) $this->collection->delete($item['collection_id']);
            }

            $result = $count && $count == $deleted;

        } else {

            if (!is_numeric($id)) {
                $this->errorAndExit($this->text('Invalid argument'));
            }

            $result = $this->collection->delete($id);
        }

        if (empty($result)) {
            $this->errorAndExit($this->text('Unexpected result'));
        }

        $this->output();
    }
public function cmdDeleteCollection()
    {
        $id = $this->getParam(0);
        $all = $this->getParam('all');

        if (empty($id) && empty($all)) {
            $this->errorAndExit($this->text('Invalid command'));
        }

        $options = null;

        if (isset($id)) {

            if ($this->getParam('type')) {
                $options = array('type' => $id);
            } else if ($this->getParam('store')) {

                if (!is_numeric($id)) {
                    $this->errorAndExit($this->text('Invalid argument'));
                }

                $options = array('store_id' => $id);
            }

        } else if (!empty($all)) {
            $options = array();
        }

        if (isset($options)) {

            $deleted = $count = 0;
            foreach ($this->collection->getList($options) as $item) {
                $count++;
                $deleted += (int) $this->collection->delete($item['collection_id']);
            }

            $result = $count && $count == $deleted;

        } else {

            if (!is_numeric($id)) {
                $this->errorAndExit($this->text('Invalid argument'));
            }

            $result = $this->collection->delete($id);
        }

        if (empty($result)) {
            $this->errorAndExit($this->text('Unexpected result'));
        }

        $this->output();
    }
public function cmdDeleteCollection ( ) { $ id = $ this -> getParam ( 0 ) ; $ all = $ this -> getParam ( 'all' ) ; if ( empty ( $ id ) && empty ( $ all ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid command' ) ) ; } $ options = null ; if ( isset ( $ id ) ) { if ( $ this -> getParam ( 'type' ) ) { $ options = array ( 'type' => $ id ) ; } else if ( $ this -> getParam ( 'store' ) ) { if ( ! is_numeric ( $ id ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid argument' ) ) ; } $ options = array ( 'store_id' => $ id ) ; } } else if ( ! empty ( $ all ) ) { $ options = array ( ) ; } if ( isset ( $ options ) ) { $ deleted = $ count = 0 ; foreach ( $ this -> collection -> getList ( $ options ) as $ item ) { $ count ++ ; $ deleted += ( int ) $ this -> collection -> delete ( $ item [ 'collection_id' ] ) ; } $ result = $ count && $ count == $ deleted ; } else { if ( ! is_numeric ( $ id ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid argument' ) ) ; } $ result = $ this -> collection -> delete ( $ id ) ; } if ( empty ( $ result ) ) { $ this -> errorAndExit ( $ this -> text ( 'Unexpected result' ) ) ; } $ this -> output ( ) ; }
Callback for "collection-delete" command
Callback for collection - delete command