Professional Documents
Culture Documents
Báo cáo cuối học phần
Báo cáo cuối học phần
BO CO THC TP K THUT CNG TY TRUE PLUS ti: Xy dng modun Simple Affiliate cho magento
H Ni 8/12/2013
1 Mc lc
2 3 4 5 Li cm n .........................................................................................................3 Gii thiu v cng ty ..........................................................................................4 Qu trnh thc tp ..............................................................................................5 C bn v magento.............................................................................................6 5.1 Magento l g? ...............................................................................................6 5.2 Cu trc mt module magento ......................................................................7 6 Cc sn phm trong qu trnh thc tp ..............................................................9 6.1 Website bn hng n gin ...........................................................................9 6.2 Modun Emailmarketing...............................................................................10 7 Module Simple Affiliate ..................................................................................12 7.1 Xy dng backend .......................................................................................13 7.1.1 7.1.2 7.2.1 7.2.2 7.2.3 Manage Accounts...............................................................................13 Manage Transactions .........................................................................15 Thng tin acccount.............................................................................17 Gi email............................................................................................18 Trang rt tin......................................................................................19
7.3 X l cc event ............................................................................................19 7.4 Cu hnh cho module ...................................................................................21 7.5 Demo giao din v chc nng chnh ...........................................................22 8 BNG NH GI KT QU THC TP DOANH NGHIP ...................27
2 Li cm n
Qua t thc tp va ri gip em c thm nhiu kin thc mi b ch, trau di thm k nng lm vic nhm cng nh c tip xc v lm vic vi mi trng lm vic thc t, gip em tch ly thm kinh nghim lm vic Em xin chn thnh cm n cc thy c trong vin Cng ngh thng tin & truyn thng t chc t thc tp b ch ny Em cng xin gi li cm n n lnh o cng ty True Plus to iu kin,gip ,to ra mi trng cho chng em c c hi lm vic cng nh hc tp trong iu kin rt tt. Cui cng em xin gi li cm n n cc anh hng dn trc tip cng ty, gip ,gii p thc mc, gip em hon thnh cc cng vic c cng ty giao
- Cung cp gii php cho cc h thng thng mi in t. - Xy dng h thng thng mi in t da trn Magento. - Vit cc extension cho Magento- mt h thng m ngun m rt chuyn nghip dnh cho E-Commerce. - Giaytot.vn website bn giy trc tuyn ln nht Vit Nam - Himita.com web bn hng handmade Magento: Magento l mt h thng thng mi in t giu tnh nng c xy dng trn nn tng cng ngh M Ngun M (OS) nhm cung cp cho thng mi trc tuyn mt kh nng linh hot cha tng c cng vi vic kim sot giao din,ni dung, m rng chc nng cc k thn thin.Tng tc qun tr bng hnh nh trc gic v a site l sc mnh ni bt ca magento.Vic Ti u ha cng c tm kim v qun tr th mc uyn chuyn gip cho magento c th thch ng vi bt k nhu cu,hnh thc v mc ca kinh doanh trc tuyn t cng vic kinh doanh nhng mt hng n l cho ti a dng ha sn phm trn mt site v nhiu site.
4 Qu trnh thc tp
Xy dng website bn hng n gin Tm hiu v xy dng frontend cho modun Email marketing Tm him v xy dng backend trong magento cho modun Email marketing Tm hiu v xy dng phn gi Email cho modun Email marketing Tm hiu v vit cc event gim gi cho Email marketing Tm hiu check out v vit check out cho modun Email Marketing Xy dng modun Simple Affiliate
15/6 21/6
22/6 28/6
29/6 7/7
Controller: l thnh phn tip nhn cc request t pha ngi dng c gi n Server thng qua browser. Controller yu cu View (Layout trong Magento) render ra cc on m HTML (bao gm c CSS v Javascript). Sau tr v pha browser hin th cho ngi dng. View: trong Magento, View bao gm cc Layout (nh ngha bng cc file XML), Block (cc class PHP), v Template (cc file .phtml). Layout c nhim v render ra cc on m HTML. Layout c th ly d liu t database thng qua cc Model Objects. Model: trong Magento, Model bao gm 2 thnh phn: Object Model v Resource Model. Trong , Object Model khng lm vic trc tip vi database. N c nhim v lu tr d liu tm thi sau khi c ly ra t 7
database. Ngoi ra, n cung cp cc operator function nh get(), set(), load(), delete(). Resource Model l thnh phn lm vic trc tip vi database. Sau khi truy vn database, d liu s c chuyn vo Object Model lu tr tm thi.
View
Controller
Model
Layout
Template
Cu trc th mc Cc module ca Magento c lu tr trong 3 th mc: app/code/core: y l th mc cha cc module core ca Magento app/code/local : th mc ny cha cc module mt ph do cc provider pht trin. app/code/community : th mc ny cha cc module min ph c pht trin bi cng ng Magento. 8
10
11
Thit k C s d liu : Bng simpleaffiliate_account gm cc field sau: account_id: Id banner (int(11) unsigned, kha chnh) customer_id: id ca customer account (int(11) unsigned, kha ph tr n entity_id ca bng customer_entity) firstname: (varchar 255) lastname: (varchar 255) email: (varchar 255) balance: tng s tin hin ti (decimal(12,4)) total_received: tng s tin commission nhn c (decimal(12,4)) joined: thi gian to account (datetime) status: Disable/ Enable (tinyint(1)) 12
Bng simpleaffiliate_transaction gm cc field sau: transaction_id: Id banner (int(11) unsigned, kha chnh) order_id: increment id ca order (bng sales_flat_order) (int(11) unsigned) affiliate_id: id account trong bng simpleaffiliate_account (int(11) unsigned) order_total: tng gi tr n hng (decimal(12,4)) commission: s tin affiliate nhn c (decimal(12,4)) store: ID ca store m transaction c to ra (smallint(6)) created: thi gian to (datetime) status: Complete/ Pending (tinyint(1))
13
14
16
public function saveAction() { $firstname = '' . $this->getRequest()->getPost('firstname'); $lastname = '' . $this->getRequest()->getPost('lastname'); $email = '' . $this->getRequest()->getPost('email'); $id = '' . $this->getRequest()->getParam('id'); if ((isset($firstname) && ($firstname != null)) && (isset($email) && ($email != null)) && (isset($lastname) && ($lastname != null)) && (isset($id) && ($id != null))) { $affiliate = Mage::getModel('affiliate/account'); $affiliate->load($id) ->setData('firstname', $firstname) ->setData('lastname', $lastname) ->setData('email', $email); $affiliate->save(); } $this->_redirect('affiliate/account/index'); }
17
7.2.2 Gi email
To form gi email ti front end: - Cho php nhp nhiu email, ngn cch nhau bi du phy - Ni dung email bt k nhng khi ngi nhn s c link ti website mua hng,khi mua hng bng ng link ny,khch hng s c gim gi v ngi gi s c hng hoa hng t phin mua hng
Hm x l gi email ti IndexController:
public function sendemail(){ $templateId = Mage::getStoreConfig('emailmarketting/general/template');
$mailSubject = 'HI this is a test mail.'; $name = $this->getNameSender(); $email = $this->getEmailSender(); $sender = array('name' => $name,
'email' => $email); $message = $this->getData('message'); $datacontact = Mage::getModel('emailmarketting/emailmarketting')->getCollection()>addFilter('group_id', $id_group); foreach ($datacontact as $row){ $email_contact = $row->getData('email'); $name_contact = $row->getData('name'); $vars = Array( 'message' => $message, 'email_sender' => $email, 'name_contact' => $name_contact, 'url' => Mage::getUrl(), 'cookie' => Mage::getModel('core/cookie')>get('frontend')
18
7.3 X l cc event
khi cc khch hng vo link gi t Affiliate mua hng th c gim gi,chng ta s dng c ch pht event trong magento gim gi cho sn phm, thc hin iu ny trong module em s dng cc event sau: catalog_product_collection_load_after() catalog_product_get_final_price() sales_order_place_after() controller_action_postdispatch_customer_account_logout()
s dng cc event ny th cn phi khi bo trong file config.xml. V vit phng thc x l chng file Magestore\Affiliate\Model\Observer.php Mt vi hm x l event trong module:
19
public function productLoadAfter($observer){ $product_collection = $observer['collection']; if(isset($_COOKIE['affiliate_id'])&&($_COOKIE['affiliate_id'] == Mage::getModel('affiliate/account')->load($_COOKIE['affiliate_id'])>getAccountId())){ foreach($product_collection as $item){ $price_pro= $item->getFinalPrice(); if(Mage::getStoreConfig('affiliate/general/discount_type') == 1){ $final_price = $price_pro ($price_pro*Mage::getStoreConfig('affiliate/general/discount')/100); } else { $final_price = $price_pro Mage::getStoreConfig('affiliate/general/discount')/100; } $item->setFinalPrice($final_price); } } }
20
public function productGetFinalPrice($observer){ $item = $observer->getEvent()->getProduct(); if(isset($_COOKIE['affiliate_id'])&&($_COOKIE['affiliate_id'] == Mage::getModel('affiliate/account')->load($_COOKIE['affiliate_id'])>getAccountId())){ $price = $item->getFinalPrice(); if(Mage::getStoreConfig('affiliate/general/discount_type') == 1){ $final_price = $price ($price*Mage::getStoreConfig('affiliate/general/discount')/100); } else { $final_price = $price Mage::getStoreConfig('affiliate/general/discount')/100; } $item->setFinalPrice($final_price); } } -
vit phn ny cn phi sa file cu hnh module system.xml Giao din cu hnh
21
22
23
Khi khch hng click vo link ca Affiliate v mua hng s thy c gim gi
24
25
Sau khi Addmin to invoice cho n hng th ti khon Affiliate s c cng tin hoa hng
Khch hng c th rt tin ca mnh ti y, sau admin s chuyn tin vo ti khon ca Affiliate
26
Ngi nh gi: 27