Customer Balance/Store Credit은 마젠토 엔터프라이즈 버전에 있는 기능입니다.
Customer Balance나 Store Credit은 마젠토에서 서로 같은 의미로 사용됩니다.
마젠토의 관리자 모드에서는 "Store Credit"이라는 어휘를 사용하지만, 마젠토 코어 코드에서는 "Customer Balance"라는 어휘를 사용합니다.
왜 그렇게 헷갈리게 해놓았는지는 모르지만.. 뭐.. 이유가 있겠죠.
기본적으로 이 기능은 손님이 계정에 스토어 크레딧을 저장해 두었다가 나중에 체크아웃할때 사용할수 있는 기능이며,
사이트 운영자가 손님에게 refund 해줄때도 크레딧카드에 해줄필요 없이 계정에 크레딧으로 돌려주게 되므로 운영자 입장에서는 여러모로 유용하게 사용될수 있습니다.
사실 스토어 크레딧은 마젠토의 관리자 모드에서 수동으로 조정할수 있지만, 여러명의 손님에게 벌크로 스토어 크레딧을 지정해 줄 경우 아래의 코드가 유용하게 사용될것 입니다.
[ccln_php]
// 스토어 크레딧을 주려는 손님의 이메일주소
$customerEmail = "email@email.com";
// 손님에게 주려는 크레딧의 양
$deltaAmount = 100;
// 커스토머 모델 로딩
$customer = Mage::getModel('customer/customer');
$customer->setWebsiteId(Mage::app()->getWebsite()->getId());
// $customer->load($customerId); 로 해도 무관함
$customer->loadByEmail($customerEmail);
if($customer->getId()) {
// 밸런스 모델 로딩
$balance = Mage::getModel('enterprise_customerbalance/balance')->setCustomer($customer);
$balance->setWebsiteId($customer->getWebsiteId());
$balance->loadByCustomer();
// 밸런스 값 세팅
$balance->setAmountDelta($deltaAmount);
// 밸런스 메모 입력
$balance->setUpdatedActionAdditionalInfo('Balance added by php script');
// 밸런스가 책정되면 자동으로 이메일이 보내지지만, 아래와같이 'false'를 세팅해두면 이메일을 보내지 않습니다.
$balance->setNotifyByEmail(false);
// 저장
$balance->save();
}
?>
[/ccln_php]
밸런스의 값을 세팅하는 $balance->setAmountDelta($deltaAmount); 에서 $deltaAmount 의 값은 -100을 지정하는 경우 현재 밸런스에서 100달러를 빼게 되고, 100을 지정하면 100달러를 더하게 됩니다.
그리고 $balance->setNotifyByEmail(false); 를 사용하지 않으면 기본적으로 자동 이메일을 보내게 되니 유념하시기 바랍니다.
Monday, January 21, 2013
Saturday, November 17, 2012
마젠토 region 과 country 코드
마젠토에는 국가별 코드와 이름이 이미 데이터베이스에 기본적으로 저장되어있고, 미국같은 경우는 state 코드/이름 또한 저장되어있습니다.
간혹 개발자가 커스텀으로 모듈이나 템플릿을 만드는 도중 마젠토 데이터베이스에 저장되어있는 국가(country)나 state(region)을 불러내야 할 경우가 있는 있는데, 아마도 아래 코드가 도움이 되리라 생각됩니다.
[ccln_php]
// 국가의 콜렉션 로딩
$countryCollection = Mage::getModel('directory/country_api')->items();
// 위의 콜렉션을 select dropdown box에 넣어야 할 경우
?>
[/ccln_php]
국가의 콜렉션을 사용하려면 directory/country_api 모델을 사용해야 합니다.
마찬가지로 region 콜렉션을 사용하려면 아래와 같이 directory/region_api 모델을 사용해야 합니다.
[ccln_php]
// region 콜렉션 로딩
// $counotryCode 는 국가 코드
$regionCollection = Mage::getModel('directory/region_api')->items($countryCode);
// 위의 콜렉션을 select dropdown box에 넣어야 할 경우
?>
[/ccln_php]
국가 코드로 국가 이름 불러오기
[ccln_php]
$countryName = Mage::getModel('directory/country')->load($countryCode)->getName();
?>
[/ccln_php]
간혹 개발자가 커스텀으로 모듈이나 템플릿을 만드는 도중 마젠토 데이터베이스에 저장되어있는 국가(country)나 state(region)을 불러내야 할 경우가 있는 있는데, 아마도 아래 코드가 도움이 되리라 생각됩니다.
[ccln_php]
// 국가의 콜렉션 로딩
$countryCollection = Mage::getModel('directory/country_api')->items();
// 위의 콜렉션을 select dropdown box에 넣어야 할 경우
?>
[/ccln_php]
국가의 콜렉션을 사용하려면 directory/country_api 모델을 사용해야 합니다.
마찬가지로 region 콜렉션을 사용하려면 아래와 같이 directory/region_api 모델을 사용해야 합니다.
[ccln_php]
// region 콜렉션 로딩
// $counotryCode 는 국가 코드
$regionCollection = Mage::getModel('directory/region_api')->items($countryCode);
// 위의 콜렉션을 select dropdown box에 넣어야 할 경우
?>
[/ccln_php]
국가 코드로 국가 이름 불러오기
[ccln_php]
$countryName = Mage::getModel('directory/country')->load($countryCode)->getName();
?>
[/ccln_php]
Tuesday, October 30, 2012
Zend Framework 1 and Zend Framework 2
Zend, a PHP company, released Zend Framework 2 stable version recently and I started working on some projects using Zend Framework 2 right after it came out.
I've been working on Magento(an E-Commerce platform that is built on top of Zend Framework 1) for last 4 years.
At the time I started working on Magento, I knew what Zend Framework was but never had any experience with it.
I had more experience with CodeIgniter and I thought CodeIgniter would be a better platform for its simplicity.
However, after I worked on Magento for several months, I became a big fan of Magento and Zend Framework.
Of course, I've been struggling for first couple weeks because of its complexity - I wasn't familiar with Singleton pattern and EAV model.
Now I have more favor on Zend Framework over CodeIgniter.
I would say Zend Framework is complex and difficult to learn than any other PHP frameworks out there, but I think it's the best framework on the market right now.
Features and concepts overview on ZF1 and ZF2:
Main features on Zend Framework 1:
Zend Framework 2 resembles Zend Framework 1 in many ways, but it works differently.
Main features on Zend Framework 2:
Useful resources on ZF2:
I've been working on Magento(an E-Commerce platform that is built on top of Zend Framework 1) for last 4 years.
At the time I started working on Magento, I knew what Zend Framework was but never had any experience with it.
I had more experience with CodeIgniter and I thought CodeIgniter would be a better platform for its simplicity.
However, after I worked on Magento for several months, I became a big fan of Magento and Zend Framework.
Of course, I've been struggling for first couple weeks because of its complexity - I wasn't familiar with Singleton pattern and EAV model.
Now I have more favor on Zend Framework over CodeIgniter.
I would say Zend Framework is complex and difficult to learn than any other PHP frameworks out there, but I think it's the best framework on the market right now.
Features and concepts overview on ZF1 and ZF2:
Main features on Zend Framework 1:
- MVC(Model View Controller) architecture
- Singleton
- Registries
- Hard & Soft coded Dependencies
- Loosely coupled architecture
Zend Framework 2 resembles Zend Framework 1 in many ways, but it works differently.
Main features on Zend Framework 2:
- Event Driven Services - Event Manager & Service Manager
- Dependency Injection - to avoid dependencies, ZF2 uses events
- Aspect Oriented Programming - shape the workflow using event manager
- Namespaces - requires PHP 5.3
- Lambda functions
- developers can install only the components desired - don't need to install entire framework
Useful resources on ZF2:
Labels:
CodeIgniter,
Image,
Magento,
Zend Framework,
ZF1,
ZF2
Wednesday, October 17, 2012
Richard Dawkins at Macky Auditorium
I was at Macky Auditorium(University of Colorado at Boulder) to see evolutionary biology icon and one of my favorite scientists - Richard Dawkins - Monday night.
Dr. Dawkins was there to have a speech/lecture on very basic natural world questions - but very hard for ordinary people to answer - such as What are things made of? What is reality? Why do bad things happen? Are we alone?, etc.
His explanations are all evidence-based, precise and accurate. His book "The Magic of Reality" is even more descriptive and well explained, even middle school kids can understand.
It was just amazing to see him having a speech in auditorium and also in person at the book signing session.
He looked little older than I imagined, but maybe that's because I only have seen his old photos and movie clips.
Dr. Dawkins was there to have a speech/lecture on very basic natural world questions - but very hard for ordinary people to answer - such as What are things made of? What is reality? Why do bad things happen? Are we alone?, etc.
His explanations are all evidence-based, precise and accurate. His book "The Magic of Reality" is even more descriptive and well explained, even middle school kids can understand.
It was just amazing to see him having a speech in auditorium and also in person at the book signing session.
He looked little older than I imagined, but maybe that's because I only have seen his old photos and movie clips.
Sunday, October 14, 2012
새로운 디자인
새로운 디자인으로 블로그를 바꿨다.
이미지 사이즈가 엄청 큰걸 요구하지만 그래도 사진 갤러리가 제일 맘에든다.
여전히 사진 작업해야 할것들이 조금 남아있고, 다른것들은.. 맘에 들지 않거나 제대로 작동하지 않는것들이 몇가지 있는데.. 그것들은 천천히 하나씩 고치기로 하고..
일단 오늘은 이걸로 끝.
이미지 사이즈가 엄청 큰걸 요구하지만 그래도 사진 갤러리가 제일 맘에든다.
여전히 사진 작업해야 할것들이 조금 남아있고, 다른것들은.. 맘에 들지 않거나 제대로 작동하지 않는것들이 몇가지 있는데.. 그것들은 천천히 하나씩 고치기로 하고..
일단 오늘은 이걸로 끝.
Subscribe to:
Posts (Atom)