Magentoは、ティア価格設定で製品をグループ化しました
-
16-10-2019 - |
質問
2つのシンプルな製品を備えたグループ製品を作成しました。たとえば、シンプルな製品にはティア価格があります。たとえば、たとえば、
Simple product -1: tier pricing : Qty Price
2 100
3 75
5 60
Simple product -2: tier pricing: Qty Price
2 110
3 80
<?php if ($_hasAssociatedProducts): ?>
<?php foreach ($_associatedProducts as $_items): ?>
<?php $_items->setData('tier_price',null); ?>
<?php $_tierPrices = $this->getTierPrices($_items); ?>
<?php foreach ($_tierPrices as $key => $value): ?>
<th><?php echo $value['price_qty']; ?></th>
<?php endforeach; ?>
<?php endforeach; ?>
<?php endif; ?>
上記のコードはすべての数量を返します 2 3 5 2 3
繰り返される「数量」値を削除し、一意の値のみを表示するにはどうすればよいですか?
解決
@pspahnのコメントは正しいです。 array_unique()
複製を削除します。コードの例では、次のように使用できます。
<?php if ($_hasAssociatedProducts): ?>
<?php $qtys = array();
foreach ($_associatedProducts as $_items): ?>
<?php $_items->setData('tier_price',null); ?>
<?php $_tierPrices = $this->getTierPrices($_items); ?>
<?php foreach ($_tierPrices as $key => $value): ?>
<?php $qtys[] = $value['price_qty']; ?>
<?php endforeach; ?>
<?php endforeach;
array_unique($qtys); ?>
<?php for ($i=0;$i<count($qtys);$i++): ?>
<th><?php echo $qtys[$i]; ?></th>
<?php endfor; ?>
<?php endif; ?>
これは出力されます 2 3 5
あなたの例に基づいて。
このような数量を表示したいだけでしたか?
所属していません magento.stackexchange