문제

4 개의 상점이있는 Magento 웹 사이트가 있습니다.각 고객마다 서로 다른 컷 오프 시간이 각 저장소에 할당됩니다.

사용자는 한 번에 하나의 저장소에서만 제품을 추가하도록 제한됩니다.사용자가 확인할 때 페이지를 추가 한 상점의 절단 시간을 가져와야합니다.

저장 코드를 얻을 수있었습니다.

상점 삭제를위한 고객 속성은 아래

과 같습니다.
`delivery_cutoff_time_abc` // here abc is the store code
`delivery_cutoff_time_def` // here def is the store code
`delivery_cutoff_time_ghi` // here ghi is the store code
`delivery_cutoff_time_jkl` // here jkl is the store code
.

장바구니에 추가 된 제품을 기반으로합니다. ITSabc 또는 def 또는 So.

이제는 고객 객체에서 아래에서 값을 가져 가야합니다

$customer = Mage::getSingleton('customer/session')->getCustomer();
$customer->getDeliveryCutoffTimeAbc();
.

이렇게하면 아래에서 저장 코드가 있습니다

$storeCode = "abc";

아래의 동적을 사용해야합니다

$customer->getDeliveryCutoffTime.$storeCode();
.

가치가 없습니다.어떻게 동적으로 만들 수 있습니까?

도움이 되었습니까?

해결책

시도

$storeCode = ucfirst("abc");

$function = "getDeliveryCutoffTime".$storeCode;

$customer->$function();
.

다른 팁

PHP에서는 다음과 같이 수행 할 수도 있습니다.

$storeCode = "abc";
$customer->{"getDeliveryCutoffTime" . ucfirst($storeCode)}();
.

이 Magento "Magic"Getter 메서드는 PeneraCodiceTag 코드 메소드를 결국 호출합니다.따라서 getData()getDeliveryCutoffTimeAbc() 호출을 초래합니다.

그래서 당신은 또한 이것을 즉시 전화 할 수 있습니다 :

$storeCode = "abc";
$customer->getData("delivery_cutoff_time_" . $storeCode);
.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top