public function getOrderedNumber()
    {
        $orderedProductsNumber = Order::find()->select('count')->joinWith('orderProducts')->where(['product_id' => $this->id])->sum('count');
        return $orderedProductsNumber ?? 0;
    }
public function getOrderedNumber()
    {
        $orderedProductsNumber = Order::find()->select('count')->joinWith('orderProducts')->where(['product_id' => $this->id])->sum('count');
        return $orderedProductsNumber ?? 0;
    }
public function getOrderedNumber ( ) { $ orderedProductsNumber = Order :: find ( ) -> select ( 'count' ) -> joinWith ( 'orderProducts' ) -> where ( [ 'product_id' => $ this -> id ] ) -> sum ( 'count' ) ; return $ orderedProductsNumber ?? 0 ; }
Gets number of units that have already bought.
@return int|mixed
Gets number of units that have already bought .