2012-02-13 4 views
3

Magento (v1.6)에서 다른 웹 사이트의 일부 기능인 을 미러링하려고했습니다. 이 예에서 상점 소유자 인 은 계층에 판매 가격을 적용하는 기능을 설정했습니다. (관리/제품/가격 판매 가능성) 판매 가격 을 적용하여 (래퍼로서 가장 가능성이 tierprices.phtml)Magento Tier 판매 가격은?

나는 그것을 할 정확하게하는 방법을 알아내는 작업을했습니다

하지만,하지 은 그 어느면에서도 진전을 보았습니다. 이 사람이 어떻게 을 구축했는지 알 수 있습니까?

if($_tierPrices) { 
     echo '<style> 
       .strikeRow  {text-decoration: line-through;} 
       .saleRow td  {color:red;} 
       .quantityRow {background: #eef} 
       td    {padding:3px 9px; border: 1px solid #fc0;} 
      </style>';   // temporary styling 

     $q = "<td>Quantity</td>"; 
     $p = "<td>{$_product->getName()}</td>"; 
     $s = "<td>Reduced Price</td>"; 

     foreach ($_tierPrices as &$tier) { 
     #$tier['tier_sale'] = '0.00'; // trick the dump into thinking there is a product sale 
      if($tier['price_qty'])  { $q .= "<td>{$tier['price_qty']}</td>"; } 
      if($tier['price'])   { $p .= "<td>".number_format($tier['price'], 2, '.', '')."</td>"; } 
      if($tier['tier_sale'])  { $s .= "<td>{$tier['tier_sale']}</td>"; } 
     } 

     $q = "<tr class='quantityRow'>{$q}</tr>"; 
     $p = ($_tierPrices[0]['tier_sale'])? "<tr class='strikeRow'>{$p}</tr>" : "<tr>{$p}</tr>"; 
     $s = ($_tierPrices[0]['tier_sale'])? "<tr class='saleRow'>{$s}</tr>" : ''; 

     echo "<tbody>$q $p $s</tbody></table>"; 

    } 

그리고 전체 소스 : 여기

가 표 코드 예제 웹 사이트 여기 http://www.epromos.com/product/2801001.html

것입니다 당신이 찾고있는 것을 확신

<?php 
/** 
* @see Mage_Catalog_Block_Product_View 
*/ 
$_product = $this->getProduct(); 
$_tierPrices = $this->getTierPrices(); 
$_finalPriceInclTax = $this->helper('tax')->getPrice($_product, $_product->getFinalPrice(), true); 

/** @var $_catalogHelper Mage_Catalog_Helper_Data */ 
$_catalogHelper = Mage::helper('catalog'); 

$_weeeTaxAmount = Mage::helper('weee')->getAmountForDisplay($_product); 

if (Mage::helper('weee')->typeOfDisplay($_product, array(1,2,4))) { 
    $_weeeTaxAttributes = Mage::helper('weee')->getProductWeeeAttributesForDisplay($_product); 
} 

if (count($_tierPrices) > 0) { 

    // start table group with class type if (obj)getInGrouped() == 1 
    echo ($this->getInGrouped()) ? '<table class="tier-prices-grouped product-pricing-grouped">' : '<table class="tier-prices product-pricing">'; 

    // assign tier pricing to $_tierPrices 
    if ($this->getInGrouped()) { 
     $_tierPrices = $this->getTierPrices($_product); 
    } 

     Mage::helper('weee')->processTierPrices($_product, $_tierPrices); 

    foreach ($_tierPrices as $_price) { 

     echo '<tr>'; 

     if ($_catalogHelper->canApplyMsrp($_product)) { 

      if ($this->getInGrouped()) { 

       echo $this->__('Buy %1$s for', $_price['price_qty']) .':'; 

      } else { 

       echo $this->__('Buy %1$s', $_price['price_qty']); 

      } 

     } else { 

       if ($this->helper('tax')->displayBothPrices()) { 

        if (Mage::helper('weee')->typeOfDisplay($_product, 0)) { 

         echo $this->__('Buy %1$s for %2$s (%3$s incl. tax) each', $_price['price_qty'], $_price['formated_price_incl_weee_only'], $_price['formated_price_incl_weee']); 

        } elseif(Mage::helper('weee')->typeOfDisplay($_product, 1)) { 

          echo $this->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price_incl_weee_only']); 

          if ($_weeeTaxAttributes) { 

           echo '(<small>'; 
           echo $this->__('%1$s incl tax.', $_price['formated_price_incl_weee']); 

           $separator = ' + '; 

            foreach ($_weeeTaxAttributes as $_attribute) { 

             echo $separator; 
             echo $_attribute->getName() .': '. Mage::helper('core')->currency($_attribute->getAmount()); 

            } 

           echo '</small>)'; 

          } 

          echo $this->__('each'); 

        } elseif(Mage::helper('weee')->typeOfDisplay($_product, 4)) { 

          echo $this->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price_incl_weee_only']); 

          if ($_weeeTaxAttributes) { 

           echo '(<small>'; 
           echo $this->__('%1$s incl tax.', $_price['formated_price_incl_weee']); 

           $separator = ' + '; 

            foreach ($_weeeTaxAttributes as $_attribute) { 

             echo $separator; 
             echo $_attribute->getName() .': '. Mage::helper('core')->currency($_attribute->getAmount()+$_attribute->getTaxAmount()); 

            } 

           echo '</small>)'; 

          } 

          echo $this->__('each'); 

        } elseif(Mage::helper('weee')->typeOfDisplay($_product, 2)) { 

          echo $this->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price']); 

          if ($_weeeTaxAttributes) { 

           echo '(<small>'; 

            foreach ($_weeeTaxAttributes as $_attribute) { 

             echo $_attribute->getName() .': '. Mage::helper('core')->currency($_attribute->getAmount()); 

            } 

           echo $this->__('Total incl. Tax: %1$s', $_price['formated_price_incl_weee']); 
           echo '</small>)'; 

          } 

          echo $this->__('each'); 

        } else { 

          echo $this->__('Buy %1$s for %2$s (%3$s incl. tax) each', $_price['price_qty'], $_price['formated_price'], $_price['formated_price_incl_tax']); 

        } 

       } else { 

        if ($this->helper('tax')->displayPriceIncludingTax()) { 

         if (Mage::helper('weee')->typeOfDisplay($_product, 0)) { 

           echo $this->__('Buy %1$s for %2$s each', $_price['price_qty'], $_price['formated_price_incl_weee']); 

         } elseif(Mage::helper('weee')->typeOfDisplay($_product, 1)) { 

           echo $this->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price_incl_weee']); 

           if ($_weeeTaxAttributes) { 

            echo '(<small>'; 
            $separator = ''; 

            foreach ($_weeeTaxAttributes as $_attribute) { 

              echo $separator; 
              echo $_attribute->getName() .': '. Mage::helper('core')->currency($_attribute->getAmount()); 

             $separator = ' + '; 

            } 

            echo '</small>)'; 

           } 

           echo $this->__('each'); 

         } elseif(Mage::helper('weee')->typeOfDisplay($_product, 4)) { 

           echo $this->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price_incl_weee']); 

           if ($_weeeTaxAttributes) { 

            echo '(<small>'; 
            $separator = ''; 

            foreach ($_weeeTaxAttributes as $_attribute) { 

              echo $separator; 
              echo $_attribute->getName() .': '. Mage::helper('core')->currency($_attribute->getAmount()+$_attribute->getTaxAmount()); 

             $separator = ' + '; 

            } 

            echo '</small>)'; 

           } 

           echo $this->__('each'); 

         } elseif(Mage::helper('weee')->typeOfDisplay($_product, 2)) { 

           echo $this->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price_incl_tax']); 

           if ($_weeeTaxAttributes) { 

            echo '(<small>'; 

             foreach ($_weeeTaxAttributes as $_attribute) { 

              echo $_attribute->getName() .': '. Mage::helper('core')->currency($_attribute->getAmount()); 

             } 

            echo $this->__('Total incl. Tax: %1$s', $_price['formated_price_incl_weee']); 
            echo '</small>)'; 

           } 

           echo $this->__('each'); 

         } else { 

           echo $this->__('Buy %1$s for %2$s each', $_price['price_qty'], $_price['formated_price_incl_tax']); 
         } 

        } else { 

         if (Mage::helper('weee')->typeOfDisplay($_product, 0)) { 

           echo $this->__('Buy %1$s for %2$s each', $_price['price_qty'], $_price['formated_price_incl_weee_only']); 

         } elseif(Mage::helper('weee')->typeOfDisplay($_product, 1)) { 

           echo $this->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price_incl_weee_only']); 

           if ($_weeeTaxAttributes) { 

            echo '(<small>'; 
            $separator = ''; 

             foreach ($_weeeTaxAttributes as $_attribute) { 

              echo $separator; 
              echo $_attribute->getName(); ?>: <?php echo Mage::helper('core')->currency($_attribute->getAmount()); 

             $separator = ' + '; 

             } 

            echo '</small>)'; 

           } 

           echo $this->__('each'); 

         } elseif(Mage::helper('weee')->typeOfDisplay($_product, 4)) { 

           echo $this->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price_incl_weee_only']); 

           if ($_weeeTaxAttributes) { 

            echo '(<small>'; 
            $separator = ''; 

             foreach ($_weeeTaxAttributes as $_attribute) { 

              echo $separator; 
              echo $_attribute->getName(); ?>: <?php echo Mage::helper('core')->currency($_attribute->getAmount()+$_attribute->getTaxAmount()); 

             $separator = ' + '; 

             } 

            echo '</small>)'; 

           } 

           echo $this->__('each'); 

         } elseif(Mage::helper('weee')->typeOfDisplay($_product, 2)) { 

           echo $this->__('Buy %1$s for %2$s', $_price['price_qty'], $_price['formated_price']); 

           if ($_weeeTaxAttributes) { 

            echo '(<small>'; 

             foreach ($_weeeTaxAttributes as $_attribute) { 

              echo $_attribute->getName(); ?>: <?php echo Mage::helper('core')->currency($_attribute->getAmount()); 

             } 

            echo $this->__('Total incl. Tax: %1$s', $_price['formated_price_incl_weee_only']); 
            echo '</small>)'; 

           } 

           echo $this->__('each'); 

         } else { 

           // concern 
           //echo $this->__('Buy %1$s for %2$s each', $_price['price_qty'], $_price['formated_price']); 

           $priceSchema['quantity'][] = $_price['price_qty']; 
           $priceSchema['formated_price'][] = $_price['formated_price']; 

         } 


        } 

     } 


     } // Can apply MSRP 

     if (!$this->getInGrouped()) { 

     // we need this ~ 

      // funky ass OR switch, can i rework this in a saner way? 
      if(($_product->getPrice() == $_product->getFinalPrice() && $_product->getPrice() > $_price['price']) 
      || ($_product->getPrice() != $_product->getFinalPrice() && $_product->getFinalPrice() > $_price['price'])) { 

//    echo ' '. $this->__('and') .'&nbsp;<strong class="benefit">'. $this->__('save') .'&nbsp;'. $_price['savePercent'] .'%'; 

      } 

//   echo '</strong>'; // why the hell isn't this in the OR switch??? 

     // we need this ~ 

     } 

     if ($_catalogHelper->isShowPriceOnGesture($_product)) { 

      $popupId = 'msrp-popup-' . $_product->getId() . $this->helper('core')->getRandomString(20); 

      echo '<a href="#" id="'. $popupId .'">'. $this->__('Click for price') .'</a>'; 
      echo '<script type="text/javascript">'; 

      if (!$this->getInGrouped()) { 

       echo 'var newLink = {'; 

        echo 'url: "'. $this->getAddToCartUrl($_product, array('qty' => $_price['price_qty'])) .'",'; 
        echo 'qty: "'. $_price['price_qty'] .'"'; 

       echo '};'; 

      } else { 

       echo 'var newLink = {'; 

        echo 'url: "'. $this->getAddToCartUrl($_product, array('qty' => $_price['price_qty'])) .'",'; 
        echo 'notUseForm: true'; 

       echo '};'; 

      } 

       echo 'Catalog.Map.addHelpLink('; 

        echo "$('{$popupId}'),"; 
        echo '"'. $_product->getName() .'",'; 
        echo json_encode($_price['real_price_html']) .','; 
        echo '"'. $this->helper('core')->currency($_product->getMsrp(),true,false) .'",'; 
        echo 'newLink'; 

       echo ');'; 

      echo '</script>'; 

     } else { 

      echo '<span class="msrp-price-hide-message">'. $_catalogHelper->getMsrpPriceMessage($_product) .'</span>'; 

     } 

    } 
} 

    if($_tierPrices) { 
     echo '<style> 
       .strikeRow  {text-decoration: line-through;} 
       .saleRow td  {color:red;} 
       .quantityRow {background: #eef} 
       td    {padding:3px 9px; border: 1px solid #fc0;} 
      </style>';   // temporary styling 

     $q = "<td>Quantity</td>"; 
     $p = "<td>{$_product->getName()}</td>"; 
     $s = "<td>Reduced Price</td>"; 

     foreach ($_tierPrices as &$tier) { 
     #$tier['tier_sale'] = '0.00'; // trick the dump into thinking there is a product sale 
      if($tier['price_qty'])  { $q .= "<td>{$tier['price_qty']}</td>"; } 
      if($tier['price'])   { $p .= "<td>".number_format($tier['price'], 2, '.', '')."</td>"; } 
      if($tier['tier_sale'])  { $s .= "<td>{$tier['tier_sale']}</td>"; } 
     } 

     $q = "<tr class='quantityRow'>{$q}</tr>"; 
     $p = ($_tierPrices[0]['tier_sale'])? "<tr class='strikeRow'>{$p}</tr>" : "<tr>{$p}</tr>"; 
     $s = ($_tierPrices[0]['tier_sale'])? "<tr class='saleRow'>{$s}</tr>" : ''; 

     echo "<tbody>$q $p $s</tbody></table>"; 

    } 
?> 
+0

어떻게 작동 시키시겠습니까? 각 계층 가격의 소매 가격을 일부 알고리즘에 따라 자동으로 계산하거나 수동으로 입력 하시겠습니까? btw, 그 다른 사이트 Magento되지 않습니다 : - P –

+0

솔직히 그것의 카탈로그 규칙이 중요하지 않거나 관리 패널에 백분율/총 가치로 입력 할 수 있습니다. 아무거나 작동하고 나중에 언제든지 수정할 수 있습니다. resp를 주셔서 감사합니다. – ehime

답변

1

다음은 빠른 해결책입니다.

제품의 '비용'필드를 사용하여 소매 가격이 귀하의 가격보다 높은 비율을 정의 할 수 있습니다. 기본적으로 '비용'입력란은 제품에 대해 지불 한 금액의 메모로 사용되며 프런트 엔드 어디에서나 사용되지 않습니다.

다음 템플릿 테마의/템플릿/카탈로그/제품 /보기/tierprices.phtml로 이동 $_product = $this->getProduct(); 줄 끝에서 다음 줄을 추가합니다 :

$multiplier = $_product->getData('cost'); 
$multiplier = $multiplier ? $multiplier : 1; 

을 그리고 <?php endif; ?><?php if (!$this->getInGrouped()): ?> 사이의 다음 행

Retail price: <?php echo $_coreHelper->currency($_price['price']*$multiplier, true, false) ?> 

원하는대로 스타일을 지정할 수 있습니다. 확실하지 않은 점이 있으면 알려주세요.

+0

굉장한 대답 Tim, 너는 남자 야. – ehime

관련 문제