protected function setStatusPriceRule($status)
    {
        $id = $this->getParam(0);
        $all = $this->getParam('all');

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

        $result = $options = null;

        if (isset($id)) {

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

            if ($this->getParam('trigger')) {
                $options = array('trigger_id' => $id);
            } else {
                $result = $this->price_rule->update($id, array('status' => $status));
            }

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

        if (isset($options)) {

            $updated = $count = 0;
            foreach ($this->price_rule->getList($options) as $item) {
                $count++;
                $updated += (int) $this->price_rule->update($item['price_rule_id'], array('status' => $status));
            }

            $result = $count && $count == $updated;
        }

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

        $this->output();
    }
protected function setStatusPriceRule($status)
    {
        $id = $this->getParam(0);
        $all = $this->getParam('all');

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

        $result = $options = null;

        if (isset($id)) {

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

            if ($this->getParam('trigger')) {
                $options = array('trigger_id' => $id);
            } else {
                $result = $this->price_rule->update($id, array('status' => $status));
            }

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

        if (isset($options)) {

            $updated = $count = 0;
            foreach ($this->price_rule->getList($options) as $item) {
                $count++;
                $updated += (int) $this->price_rule->update($item['price_rule_id'], array('status' => $status));
            }

            $result = $count && $count == $updated;
        }

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

        $this->output();
    }
protected function setStatusPriceRule ( $ status ) { $ id = $ this -> getParam ( 0 ) ; $ all = $ this -> getParam ( 'all' ) ; if ( ! isset ( $ id ) && ! $ all ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid command' ) ) ; } $ result = $ options = null ; if ( isset ( $ id ) ) { if ( empty ( $ id ) || ! is_numeric ( $ id ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid argument' ) ) ; } if ( $ this -> getParam ( 'trigger' ) ) { $ options = array ( 'trigger_id' => $ id ) ; } else { $ result = $ this -> price_rule -> update ( $ id , array ( 'status' => $ status ) ) ; } } else if ( $ all ) { $ options = array ( ) ; } if ( isset ( $ options ) ) { $ updated = $ count = 0 ; foreach ( $ this -> price_rule -> getList ( $ options ) as $ item ) { $ count ++ ; $ updated += ( int ) $ this -> price_rule -> update ( $ item [ 'price_rule_id' ] , array ( 'status' => $ status ) ) ; } $ result = $ count && $ count == $ updated ; } if ( empty ( $ result ) ) { $ this -> errorAndExit ( $ this -> text ( 'Unexpected result' ) ) ; } $ this -> output ( ) ; }
Sets status for one or several price rules
@param bool $status
Sets status for one or several price rules