2014-04-28 4 views
0
좀 var.For에이 같은이, 내가로 json_encode을 통해 특정 제품의 등급 가격을 얻고있다() 함수 계층 데이터를 입력 할

:얻기 계층 가격 값

var tierPrices = <?php echo json_encode($_product->getTierPrice()) ?>; 
    var getPrice = function(qty){ 
     qty = Number(qty); 
     var i = tierPrices.length; 
     while(i--) 
     { 
      if(qty >= tierPrices[i]['price_qty']){ 
       return tierPrices[i]['price']; 
      } 
     } 
     return null; 
    }; 


var price = getPrice(this.value); 

var price = "<?php echo Mage::helper('core')->currency?>"+(getPrice(this.value)); 

그러나 두 상점을위한 계층 가격의 값이 같은오고있다 : 내가 필요로하는 것은 항상 기본 디스플레이 매점에 대한 계층의 가격을 선택하기 때문에 다른 매장에 따라 가격 값을 얻을 수있다이 시도. 다른 매장 통화에 따라 계층 가격이 어떻게 책정됩니까?

답변

0

상점 id에 따라 제품을로드해야합니다.

먼저 상점 ID를 얻어야합니다.

$storeId = Mage::app()->getStore()->getId(); 

그런 다음 해당 제품을 상점 ID로로드하십시오.

$_product = Mage::getModel('catalog/product') 
     ->setStoreId($storeId) 
     ->load($key); 

그런 다음 타이어 가격을 확인하십시오.

$_product->getTierPrice(); 
+0

상점 ID가 '1'또는 상점 ID가 '2'.it 가격의 동일한 배열을 데려 오는 경우는, 계층 가격이오고있는 계층 Prices.Same 작동되지 않았습니다. –

+0

그 코드를 어떻게 따라야할까요? –

+0

$ storeId = Mage :: app() -> getStore() -> getId(); "store id is"echo $ storeId; $ products = Mage :: getModel ('catalog/product') -> setStoreId ($ storeId); $ cpid = Mage :: registry ('current_product') -> getId(); $ products-> load ($ cpid); $ array = $ products-> getTierPrice(); print_r ($ array); –