Magento Groupés Produits Avec Niveau prix
-
16-10-2019 - |
Question
J'ai créé un produit de groupe avec deux simples produit simple products.Each a niveau pricing.For exemple,
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; ?>
Les rendements de code ci-dessus tous les qté 2 3 5 2 3
.How-je supprimer les répétées « qty » valeurs et montrer que des valeurs uniques?
La solution
Commentaire de
@ pspahn est correcte. array_unique()
supprimera les doublons. Dans votre exemple de code, il pourrait être utilisé comme ceci:
<?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; ?>
Ceci affichera 2 3 5
en fonction de votre exemple.
vous venez de vouloir afficher les quantités seulement comme ça?
Licencié sous: CC-BY-SA avec attribution
Non affilié à magento.stackexchange