代码:
<?php
$productId = 646;//AM-OL-SEEKER-2PRO-OR-CA-OS-30的产品
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$productRepository = $objectManager->get('Magento\Catalog\Api\ProductRepositoryInterface');
$product = $productRepository->getById($productId);
$arrGroup = [
'0' => 'Not Login In',
'4' => 'Retail Member',
'5' => 'Diamond Member',
'7' => 'Platinum Member',
'8' => 'Gold member',
'10' => 'CAD$500 Gold member'
];
echo 'AM-OL-SEEKER-2PRO-OR-CA-OS-30 产品各用户组价格:</br>';
foreach ($arrGroup as $groupId => $groupName) {
$product->setCustomerGroupId($groupId);
echo $groupName.': '.$product->getFinalPrice().'</br>';
}
输出结果打印:
AM-OL-SEEKER-2PRO-OR-CA-OS-30 产品各用户组价格:
Not Login In: 202.95
Retail Member: 202.95
Diamond Member: 202.95
Platinum Member: 131.9200
Gold member: 142.0700
CAD$500 Gold member: 202.95
来源:oschina
链接:https://my.oschina.net/ganfanghua/blog/3171539