本文整理汇总了PHP中Magento\Mtf\Fixture\FixtureInterface::getPrice方法的典型用法代码示例。如果您正苦于以下问题:PHP FixtureInterface::getPrice方法的具体用法?PHP FixtureInterface::getPrice怎么用?PHP FixtureInterface::getPrice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Mtf\Fixture\FixtureInterface
的用法示例。
在下文中一共展示了FixtureInterface::getPrice方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: assertOnShoppingCart
/**
* Assert prices on the shopping cart
*
* @param FixtureInterface $product
* @param CheckoutCart $checkoutCart
* @return void
*
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
protected function assertOnShoppingCart(FixtureInterface $product, CheckoutCart $checkoutCart)
{
$checkoutCart->open();
/** @var CatalogProductSimple $product */
$customOptions = $product->getCustomOptions();
$checkoutData = $product->getCheckoutData();
$checkoutCartItem = isset($checkoutData['cartItem']) ? $checkoutData['cartItem'] : [];
$checkoutCustomOptions = isset($checkoutData['options']['custom_options']) ? $checkoutData['options']['custom_options'] : [];
$fixturePrice = $product->getPrice();
$specialPrice = $product->getSpecialPrice();
$cartItem = $checkoutCart->getCartBlock()->getCartItem($product);
$formPrice = $cartItem->getPrice();
if ($specialPrice) {
$fixturePrice = $specialPrice;
}
if (isset($checkoutCartItem['price'])) {
$fixturePrice = $checkoutCartItem['price'];
}
$fixtureActualPrice = $fixturePrice;
foreach ($checkoutCustomOptions as $checkoutOption) {
$attributeKey = str_replace('attribute_key_', '', $checkoutOption['title']);
$optionKey = str_replace('option_key_', '', $checkoutOption['value']);
$option = $customOptions[$attributeKey]['options'][$optionKey];
if ('Fixed' == $option['price_type']) {
$fixtureActualPrice += $option['price'];
} else {
$fixtureActualPrice += $fixturePrice / 100 * $option['price'];
}
}
\PHPUnit_Framework_Assert::assertEquals($fixtureActualPrice, $formPrice, 'Product price in shopping cart is not correct.');
}
示例2: processAssert
/**
* Assert that duplicated product is found by sku and has correct product type, product template,
* product status disabled and out of stock
*
* @param FixtureInterface $product
* @param CatalogProductIndex $productGrid
* @return void
*/
public function processAssert(FixtureInterface $product, CatalogProductIndex $productGrid)
{
$config = $product->getDataConfig();
$filter = ['name' => $product->getName(), 'visibility' => $product->getVisibility(), 'status' => 'Disabled', 'sku' => $product->getSku() . '-1', 'type' => ucfirst($config['create_url_params']['type']) . ' Product', 'price_to' => number_format($product->getPrice(), 2)];
$productGrid->open()->getProductGrid()->search($filter);
$filter['price_to'] = '$' . $filter['price_to'];
\PHPUnit_Framework_Assert::assertTrue($productGrid->getProductGrid()->isRowVisible($filter, false), 'Product duplicate is absent in Products grid.');
}
示例3: getProductPrice
/**
* Get configurable product price
*
* @param FixtureInterface $product
* @throws \Exception
* @return int
*/
protected function getProductPrice(FixtureInterface $product)
{
$price = $product->getPrice();
if (!$this->productsIsConfigured) {
return $price;
}
if (!$product instanceof ConfigurableProduct) {
throw new \Exception("Product '{$product->getName}()' is not configurable product.");
}
$checkoutData = $product->getCheckoutData();
if ($checkoutData === null) {
return 0;
}
$attributesData = $product->getConfigurableAttributesData()['attributes_data'];
foreach ($checkoutData['options']['configurable_options'] as $option) {
$itemOption = $attributesData[$option['title']]['options'][$option['value']];
$itemPrice = $itemOption['is_percent'] == 'No' ? $itemOption['pricing_value'] : $product->getPrice() / 100 * $itemOption['pricing_value'];
$price += $itemPrice;
}
return $price;
}
示例4: verifyPrice
/**
* Verify displayed product price on product page(front-end) equals passed from fixture
*
* @return string|null
*/
protected function verifyPrice()
{
if ($this->product->hasData('price') == false) {
return null;
}
$priceBlock = $this->productView->getPriceBlock();
$formPrice = $priceBlock->isOldPriceVisible() ? $priceBlock->getOldPrice() : $priceBlock->getPrice();
$fixturePrice = number_format($this->product->getPrice(), 2, '.', '');
if ($fixturePrice != $formPrice) {
return "Displayed product price on product page(front-end) not equals passed from fixture. " . "Actual: {$fixturePrice}, expected: {$formPrice}.";
}
return null;
}
示例5: getProductPrice
/**
* Get configurable product price
*
* @param FixtureInterface $product
* @throws \Exception
* @return int
*/
protected function getProductPrice(FixtureInterface $product)
{
$price = $product->getPrice();
if (!$this->productsIsConfigured) {
return $price;
}
if (!$product instanceof ConfigurableProduct) {
throw new \Exception("Product '{$product->getName}()' is not configurable product.");
}
$checkoutData = $product->getCheckoutData();
if ($checkoutData === null) {
return 0;
}
return $price;
}
示例6: prepareOptions
/**
* Preparation options before comparing
*
* @param FixtureInterface $product
* @param int|null $actualPrice
* @return array
*
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
protected function prepareOptions(FixtureInterface $product, $actualPrice = null)
{
$result = [];
$customOptions = $product->hasData('custom_options') ? $product->getDataFieldConfig('custom_options')['source']->getCustomOptions() : null;
$actualPrice = $actualPrice ? $actualPrice : $product->getPrice();
foreach ($customOptions as $customOption) {
$skippedField = isset($this->skippedFieldOptions[$customOption['type']]) ? $this->skippedFieldOptions[$customOption['type']] : [];
foreach ($customOption['options'] as &$option) {
// recalculate percent price
if ('Percent' == $option['price_type']) {
$option['price'] = $actualPrice * $option['price'] / 100;
$option['price'] = round($option['price'], 2);
}
$option = array_diff_key($option, array_flip($skippedField));
}
$result[$customOption['title']] = $customOption;
}
return $result;
}
示例7: getProductPrice
/**
* Get product price.
*
* @param FixtureInterface $product
* @return int
*/
protected function getProductPrice(FixtureInterface $product)
{
return isset($product->getCheckoutData()['cartItem']['price']) ? $product->getCheckoutData()['cartItem']['price'] : $product->getPrice();
}
示例8: assertPrice
/**
* Verify product price on category view page
*
* @param FixtureInterface $product
* @param CatalogCategoryView $catalogCategoryView
* @return void
*/
protected function assertPrice(FixtureInterface $product, CatalogCategoryView $catalogCategoryView)
{
$price = $catalogCategoryView->getListProductBlock()->getProductPriceBlock($product->getName())->getRegularPrice();
\PHPUnit_Framework_Assert::assertEquals(number_format($product->getPrice(), 2), $price, 'Product regular price on category page is not correct.');
}