2

Im trying fo find a solution to manage this. I have an item on every grouped product with a low value (5 dollar) witch is a sample of the main product.

I like to exclude the samples from minimal price calculation on category view (Starting at:) The sample item can be identified with SKU = "****SAM" or by name = "*** Sample"

Later i like to set samples free for wholesale (0.00) and would also like to exclude them from minimal price listing Starting at:

Here the code of /template/catalog/product/price.phtml How can i exclude grouped item who has "SAM" in SKU or "Sample" in name from minimal price calculation please.

 <?php if ($this->getDisplayMinimalPrice() && $_minimalPriceValue && $_minimalPriceValue < $_product->getFinalPrice()): ?>

    <?php $_minimalPriceDisplayValue = $_minimalPrice; ?>
    <?php if ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($_product, array(0, 1, 4))): ?>
        <?php $_minimalPriceDisplayValue = $_minimalPrice + $_weeeTaxAmount; ?>
    <?php endif; ?>

    <?php if ($this->getUseLinkForAsLowAs()):?>
    <a href="<?php echo $_product->getProductUrl(); ?>" class="minimal-price-link">
    <?php else:?>
    <span class="minimal-price-link">
    <?php endif?>
        <span class="label"><?php echo $this->__('As low as:') ?></span>
        <span class="price" id="product-minimal-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>">
            <?php echo $_coreHelper->currency($_minimalPriceDisplayValue, true, false) ?>
        </span>
    <?php if ($this->getUseLinkForAsLowAs()):?>
    </a>
    <?php else:?>
    </span>
    <?php endif?>
<?php endif; /* if ($this->getDisplayMinimalPrice() && $_minimalPrice && $_minimalPrice < $_finalPrice): */ ?>
</div>
<?php else: /* if (!$_product->isGrouped()): */ ?>
<?php
$_exclTax = $_taxHelper->getPrice($_product, $_minimalPriceValue);
$_inclTax = $_taxHelper->getPrice($_product, $_minimalPriceValue, true);
?>
<?php if ($this->getDisplayMinimalPrice() && $_minimalPriceValue): ?>
    <div class="price-box">
        <p class="minimal-price">
            <span class="price-label"><?php echo $this->__('Starting at:') ?></span>
            <?php if ($_taxHelper->displayBothPrices()): ?>
                <span class="price-excluding-tax">
                    <span class="label"><?php echo $this->helper('tax')->__('Excl. Tax:') ?></span>
                    <span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>">
                        <?php echo $_coreHelper->currency($_exclTax, true, false) ?>
                    </span>
                </span>
                <span class="price-including-tax">
                    <span class="label"><?php echo $this->helper('tax')->__('Incl. Tax:') ?></span>
                    <span class="price" id="price-including-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>">
                        <?php echo $_coreHelper->currency($_inclTax, true, false) ?>
                    </span>
                </span>
            <?php else: ?>
                <?php
                $_showPrice = $_inclTax;
                if (!$_taxHelper->displayPriceIncludingTax()) {
                    $_showPrice = $_exclTax;
                }
                ?>
            <span class="price" id="product-minimal-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>">
                <?php echo $_coreHelper->currency($_showPrice, true, false) ?>
            </span>
            <?php endif; ?>
        </p>
    </div>
2
  • Not sure what you mean by minimal price calculation. can you elaborate? Nov 7, 2014 at 21:15
  • i add the code where i guess the minimal price is calculated. i like to exclude Samples from there please
    – user3576
    Nov 8, 2014 at 11:13

2 Answers 2

1

I would add the sample product as a upsell or related product to show it on the grouped product price.

Then use a shopping cart price rule to set the price to 0 for certain groups. The rule should look something like this

enter image description here

enter image description here

enter image description here

1
  • many thanks for the idea, but shooping cart rules dont not affect starting at price. l like to exclude the sample from starting at price. even i like to have the correct price on item list and not only on cart.
    – user3576
    Nov 8, 2014 at 12:28
1

The minimal price is calculated by the indexer. In this process it's not that easy to get the actual product and thus it's SKU. We do however have access to the tax class for the product.

So thinking out of the box, we can create a special Tax class for samples. Then with a little modification in the indexer, we can exclude that tax class from updating the lowest price in the minimal price calculation loop:

diff --git a/app/code/core/Mage/CatalogIndex/Model/Resource/Data/Grouped.php b/app/code/core/Mage/CatalogIndex/Model/Resource/Data/Grouped.php
index 98570ef..15f4330 100644
--- a/app/code/core/Mage/CatalogIndex/Model/Resource/Data/Grouped.php
+++ b/app/code/core/Mage/CatalogIndex/Model/Resource/Data/Grouped.php
@@ -42,6 +42,8 @@ class Mage_CatalogIndex_Model_Resource_Data_Grouped extends Mage_CatalogIndex_Mo
      * @param int $store
      * @return array
      */
+    const SAMPLE_TAX_CLASS_ID = 7;
+
     public function getMinimalPrice($products, $priceAttributes, $store)
     {
         $result = array();
@@ -68,9 +70,13 @@ class Mage_CatalogIndex_Model_Resource_Data_Grouped extends Mage_CatalogIndex_Mo
                 $retreiver = Mage::getSingleton('catalogindex/retreiver')->getRetreiver($type);
                 foreach ($typeIds as $id) {
                     $finalPrice = $retreiver->getFinalPrice($id, $store, $group);
-                    if ((null === $resultMinimal) || ($finalPrice < $resultMinimal)) {
-                        $resultMinimal    = $finalPrice;
+                    if ( (null === $resultMinimal) || ($finalPrice < $resultMinimal)) {
                         $resultTaxClassId = $retreiver->getTaxClassId($id, $store);
+                        if( $resultTaxClassId != self::SAMPLE_TAX_CLASS_ID ) {
+                            $resultMinimal    = $finalPrice;
+                        }
+                        else
+                            unset($resultTaxClassId);
                     }

                     $tiers = $retreiver->getTierPrices($id, $store);

Of course, you should do this properly in an extension and the hard-coded constant there, should probably be a configuration setting.

3
  • nice idea, thank you. what if all Sample has a fixed price like 4 Dollar? can we base on this and exclude it?
    – user3576
    Nov 8, 2014 at 12:25
  • You can. But I think 6 months from now, when you introduce a percentage based catalog price rule that sets another item to 4 dollar, you're going to be sorry :).
    – user4351
    Nov 8, 2014 at 13:19
  • this will never hapopend, beacause the chance will be 1:xxxxxxx to have precise 4.ooooo dollar price. Could you tell me please how to?
    – user3576
    Nov 8, 2014 at 18:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.