2015-02-03 7 views
1

A 부분에 그룹 가격을받을 수 있습니다 : $collection = Mage::getModel('catalog/product')->getCollection();방법 젠토 백엔드

파트 B : $collection = Mage::getResourceModel('catalog/product')->getCollection();

어떻게 "그룹 가격"를 얻을? 어떨까요?

+0

안녕하세요. 질문에 대해 자세히 설명해주세요. 나는 그룹 제품 또는 번들 제품의 가격을 얻고 싶습니까? 도움을 주셔서 감사합니다. –

답변

2

희망을 잘하고 있습니다.

귀하의 문제에 따라 그룹 가격을 얻으려면 magento에서 하나의 방법을 사용하고 있지만, $ 제품의 오브젝트를 가지고있는 경우에만 전체를 사용합니다. getGroupPrice()를 사용하여 확인할 수 있습니다. 같은 예가 아래에 나와 있습니다.

<?php 
$login = Mage::getSingleton('customer/session')->isLoggedIn(); 
//Check if User is Logged In 

if($login && Mage::getSingleton('customer/session') >getCustomerGroupId()==5) 
{ 
     $groupPrices = $ProductObject->getData('group_price'); 
     $Groupprice= $groupPrices; 

     if (is_null($groupPrices)) 
     { 
     $attribute = $ProductObject->getResource()-   >getAttribute('group_price'); 
     if ($attribute) 
     { 
      $attribute->getBackend()->afterLoad($ProductObject); 
      $groupPrices = $ProductObject->getData('group_price'); 
      } 
     } 
     /* check group price exit nor not */ 
     if (!is_null($groupPrices) || is_array($groupPrices)) { 
      foreach ($groupPrices as $groupPrice) { 

      if($groupPrice['cust_group'] == Mage::getSingleton('customer/session')->getCustomerGroupId()){ 
      echo $Groupprice = $groupPrice['website_price']; 
      echo "<br/>"; 
      echo $Groupprice=$groupPrice['cust_group']; 
      break; 
      } 
      } 

     } 
     /* $Groupprice is null mean group price is not exit*/ 
     if(!is_null($Groupprice)){ 
      //group price eixts 
      ?> 
      <span class="price-label"><?php echo "Special Group Price " ?></span> 
      <?php 
     }else{ 
      //Group price is exits. 
      ?> 
      <span class="price-label"><?php echo "Now" ?></span> 
     <?php } 
    ?> 
    <?php } 

    else { ?> 
    <span class="price-label"><?php echo "Now" ?></span> 
    <?php } ?> 

희망이 예는 다음에 유용 할 것입니다.

+0

하지만 고객 그룹이없는 magento 백엔드에서 스크립트를 실행하고 싶습니다. –