本文整理汇总了PHP中Magento\Catalog\Model\Product::getQty方法的典型用法代码示例。如果您正苦于以下问题:PHP Product::getQty方法的具体用法?PHP Product::getQty怎么用?PHP Product::getQty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Catalog\Model\Product
的用法示例。
在下文中一共展示了Product::getQty方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getValue
/**
* Get the price value for one of selection product
*
* @return bool|float
*/
public function getValue()
{
if (null !== $this->value) {
return $this->value;
}
$priceCode = $this->useRegularPrice ? BundleRegularPrice::PRICE_CODE : FinalPrice::PRICE_CODE;
if ($this->bundleProduct->getPriceType() == Price::PRICE_TYPE_DYNAMIC) {
// just return whatever the product's value is
$value = $this->priceInfo->getPrice($priceCode)->getValue();
} else {
// don't multiply by quantity. Instead just keep as quantity = 1
$selectionPriceValue = $this->selection->getSelectionPriceValue();
if ($this->product->getSelectionPriceType()) {
// calculate price for selection type percent
$price = $this->bundleProduct->getPriceInfo()->getPrice(CatalogPrice\RegularPrice::PRICE_CODE)->getValue();
$product = clone $this->bundleProduct;
$product->setFinalPrice($price);
$this->eventManager->dispatch('catalog_product_get_final_price', ['product' => $product, 'qty' => $this->bundleProduct->getQty()]);
$value = $product->getData('final_price') * ($selectionPriceValue / 100);
} else {
// calculate price for selection type fixed
$value = $this->priceCurrency->convert($selectionPriceValue) * $this->quantity;
}
}
if (!$this->useRegularPrice) {
$value = $this->discountCalculator->calculateDiscount($this->bundleProduct, $value);
}
$this->value = $this->priceCurrency->round($value);
return $this->value;
}
示例2: assertProductInfo
/**
* @param \Magento\Catalog\Model\Product $product
*/
private function assertProductInfo($product)
{
$data = [1 => ['sku' => 'simple', 'name' => 'Simple Product', 'price' => '10', 'qty' => '1', 'position' => '1'], 21 => ['sku' => 'virtual-product', 'name' => 'Virtual Product', 'price' => '10', 'qty' => '2', 'position' => '2']];
$productId = $product->getId();
$this->assertEquals($data[$productId]['sku'], $product->getSku());
$this->assertEquals($data[$productId]['name'], $product->getName());
$this->assertEquals($data[$productId]['price'], $product->getPrice());
$this->assertEquals($data[$productId]['qty'], $product->getQty());
$this->assertEquals($data[$productId]['position'], $product->getPosition());
}
示例3: getValue
/**
* Get the price value for one of selection product
*
* @return bool|float
*/
public function getValue()
{
if (null !== $this->value) {
return $this->value;
}
if ($this->bundleProduct->getPriceType() == Price::PRICE_TYPE_DYNAMIC) {
$value = $this->priceInfo->getPrice(FinalPrice::PRICE_CODE)->getValue();
} else {
if ($this->product->getSelectionPriceType()) {
// calculate price for selection type percent
$price = $this->bundleProduct->getPriceInfo()->getPrice(CatalogPrice\RegularPrice::PRICE_CODE)->getValue();
$product = clone $this->bundleProduct;
$product->setFinalPrice($price);
$this->eventManager->dispatch('catalog_product_get_final_price', array('product' => $product, 'qty' => $this->bundleProduct->getQty()));
$value = $product->getData('final_price') * ($this->product->getSelectionPriceValue() / 100);
} else {
// calculate price for selection type fixed
$value = $this->product->getSelectionPriceValue() * $this->quantity;
}
}
$this->value = $this->discountCalculator->calculateDiscount($this->bundleProduct, $value);
return $this->value;
}
示例4: getQty
/**
* Retrieve Qty from item
*
* @param \Magento\Wishlist\Model\Item|\Magento\Catalog\Model\Product $item
* @return float
*/
public function getQty($item)
{
$qty = $item->getQty() * 1;
if (!$qty) {
$qty = 1;
}
return $qty;
}
示例5: getUpdateParams
/**
* Retrieve params for updating product in wishlist
*
* @param \Magento\Catalog\Model\Product|\Magento\Wishlist\Model\Item $item
*
* @return string|false
*/
public function getUpdateParams($item)
{
$itemId = null;
if ($item instanceof \Magento\Catalog\Model\Product) {
$itemId = $item->getWishlistItemId();
$productId = $item->getId();
}
if ($item instanceof \Magento\Wishlist\Model\Item) {
$itemId = $item->getId();
$productId = $item->getProduct()->getId();
}
$url = $this->_getUrl('wishlist/index/updateItemOptions');
if ($itemId) {
$params = ['id' => $itemId, 'product' => $productId, 'qty' => $item->getQty()];
return $this->_postDataHelper->getPostData($url, $params);
}
return false;
}
示例6: testGetQty
/**
* Test for get qty
*/
public function testGetQty()
{
$this->model->setQty(1);
$this->assertEquals(1, $this->model->getQty());
}
示例7: convert
/**
* {@inheritdoc}
*/
public function convert(\Magento\Catalog\Model\Product $product)
{
return [ProductLink::TYPE => $product->getTypeId(), ProductLink::SKU => $product->getSku(), ProductLink::POSITION => $product->getPosition(), ProductLink::CUSTOM_ATTRIBUTES_KEY => [[AttributeValue::ATTRIBUTE_CODE => 'qty', AttributeValue::VALUE => $product->getQty()]]];
}
示例8: convert
/**
* {@inheritdoc}
*/
public function convert(\Magento\Catalog\Model\Product $product)
{
return ['type' => $product->getTypeId(), 'sku' => $product->getSku(), 'position' => $product->getPosition(), 'custom_attributes' => [['attribute_code' => 'qty', 'value' => $product->getQty()]]];
}
示例9: getQty
/**
* {@inheritdoc}
*/
public function getQty()
{
$pluginInfo = $this->pluginList->getNext($this->subjectType, 'getQty');
if (!$pluginInfo) {
return parent::getQty();
} else {
return $this->___callPlugins('getQty', func_get_args(), $pluginInfo);
}
}