Get stock quantity.

@param string $sku
SKU string.

@return int
Quantity, 0 if status flag is set to false.
543217
public function getStockQuantity(string $sku) {
    $stock = $this->getStock($sku);

    if (empty($stock['status'])) {
      return 0;
    }

    // @TODO: For now there is no scenario in which we have quantity in float.
    // We have kept the database field to match what is there in MDC and code
    // can be updated later to match that. Casting it to int for now.
    return (int) $stock['quantity'];
  }
277249
public function getBySku(SKU $sku) : Product
    {
        if (!array_key_exists((string) $sku, $this->products)) {
            throw ProductNotFoundException::bySku($sku);
        }

        return $this->products[(string) $sku];
    }
933498
public function setSku($sku) {
        if(!$this->setModified('sku', $sku)->isModified()) {
            return $this;
        }
		$this->sku = $sku;
		return $this;
    }
344816
public function update($sku)
    {
        if (!Input::has('product')) {
            return $this->jsonErrorResponse('"product" is required.');
        }

        $product = Subbly::api('subbly.product')->update($sku, Input::get('product'), Input::get('locale', null));

        return $this->jsonResponse(array(
            'product' => $this->presenter->single($product),
        ),
        array(
            'status' => array('message' => 'Product updated'),
        ));
    }
1284163
public function setQuantity( $quantity )
	{
		if( !is_numeric( $quantity ) ) {
			throw new MShop_Order_Exception( 'Quantity is invalid. Please enter a positive integer' );
		}

		$quantity = (int) $quantity;

		if( $quantity == $this->getQuantity() ) { return; }

		if( $quantity < 1 || $quantity > 2147483647 ) {
			throw new MShop_Order_Exception( sprintf( 'Quantity must be a positive integer and must not exceed %1$d', 2147483647 ) );
		}

		$this->_values['quantity'] = $quantity;
		$this->setModified();
	}
419613
public function getQuantity() : ?int 
    {
        if ( ! $this->hasQuantity()) {
            $this->setQuantity($this->getDefaultQuantity());
        }
        return $this->quantity;
    }
895762
protected function getIdProductAbstractBySku($productAbstractSku): int
    {
        $spyProductAbstractEntity = SpyProductAbstractQuery::create()->findOneBySku($productAbstractSku);

        if (!$spyProductAbstractEntity) {
            throw new EntityNotFoundException(
                sprintf('Product abstract with SKU "%s" was not found during import.', $productAbstractSku)
            );
        }

        return $spyProductAbstractEntity->getIdProductAbstract();
    }
304142
def quantity_update(self, num_iid, quantity, session, sku_id=None, outer_id=None, aType=None):
        ''''''
        request = TOPRequest('taobao.item.quantity.update')
        request['num_iid'] = num_iid
        request['quantity'] = quantity
        if sku_id!=None:
            request['sku_id'] = sku_id
        if outer_id!=None:
            request['outer_id'] = outer_id
        if aType!=None:
            request['type'] = aType
        self.create(self.execute(request, session)['item'])
        return self
401260
def reduce_stock(self, product_id, sku_info, quantity):
        
        return self._post(
            'merchant/stock/reduce',
            data={
                "product_id": product_id,
                "sku_info": sku_info,
                "quantity": quantity
            }
        )
427098
def getSubtotal(self):
        
        if self.supplyorder_lineitems:
            return sum(
                [(Decimal(obj['Quantity']) * Decimal(obj['Price'])) for obj in self.supplyorder_lineitems])
        return 0
492665
public function count($totalItems = true)
    {
        $items = $this->getCart();

        if (!$totalItems) {
            return $items->count();
        }

        $count = 0;

        foreach ($items as $row) {
            $count += $row->qty;
        }

        return $count;
    }
323928
public function withProductRequest($sku, $qty = 1, $request = []) : CartBuilder
    {
        $result = clone $this;
        $requestInfo = array_merge(['qty'=> $qty], $request);
        $result->addToCartRequests[$sku][] = new DataObject($requestInfo);
        return $result;
    }
219897
public function getDiscount()
    {
        $amount = 0;
        $cart = ShoppingCart::get();
        $items = $cart->TotalItems;
        $discount = $cart->getDiscount();
        
        if ($this->BasePrice && $discount && $discount->Amount) {
            if ($discount->Type == "Fixed") {
                $amount = ($discount->Amount / $items) * $this->Quantity;
            } elseif ($discount->Type == "Percentage") {
                $amount = (($this->Price / 100) * $discount->Amount) * $this->Quantity;
            }
        }
        
        return $amount;
    }
863690
public function store($product_sku)
    {
        $product = Subbly::api('subbly.product')->find($product_sku);

        if (!Input::hasFile('product_image')) {
            return $this->jsonErrorResponse('"product_image" is required.');
        }

        $productImage = Subbly::api('subbly.product_image')->create(array(
            'image' => Input::file('product_image'),
        ), $product);

        return $this->jsonResponse(array(
            'product_image' => $productImage,
        ),
        array(
            'status' => array(
                'code'    => 201,
                'message' => 'ProductImage created',
            ),
        ));
    }
110053
private function releaseLock(string $sku) {
    $lock_key = self::class . ':' . $sku;
    $this->lock->release($lock_key);
  }
263094
public function getAmount($orderIndex = 0)
    {
        $orderStatuses = $this->getOrderStatuses();
        return array_key_exists('amount', $orderStatuses[$orderIndex]) ? $orderStatuses[$orderIndex]['amount'] : null;
    }
594989
public function prices() : Float
    {
        $total = 0;

        if( ! empty(Properties::$items) ) foreach( Properties::$items as $values )
        {
            $quantity = (int)   ($values['quantity'] ?? 1);
            $price    = (float) ($values['price']    ?? 0);

            $total += $price * $quantity;
        }

        return $total;
    }