simpleaffiliate requirements
TRANSCRIPT
-
SIMPLE AFFILIATE REQUIREMENTS
M t:
Affiliate l module cho php cc ch store (ca hng) to ra mng li gii thiu khch n mua
hng thng qua cc affiliates (ngi mi gii). Vi mi order (n hng) thnh cng, affiliate s
nhn c 1 lng commission (tin hoa hng). ng thi, khch hng mua n hng c
th c nhn 1 lng discount (gim gi). Affiliates thc hin vic gii thiu khch hng thng
qua cc banner m store cung cp. Cc affiliates t banner ln blog/ forum/ social network, mi
banner c gn link n website bn hng. Cc link ny c cha thng tin v affiliate (c th l
affiliate ID). V vy khi khch hng mua hng sau khi click vo cc link ny, module s kim
tra c thng tin affilaite v to ra cc transaction (giao dch). T cc affiliates s nhn c
commission.
Module Affiliate cung cp cc chc chnh nng sau:
Qun l banner (thm, sa, xa, upload nh)
Qun l affiliate account (thm, sa, xa, upload nh)
Qun l transaction (lit k, tm kim)
Setting lng commission/ disccount cho mi order mua hng
ng k lm affiliate
Cho php affiliates ly banner v cc on m nhng HTML a ln blog/ forum
Cho php affiliates kim tra danh sch cc transaction, thng k balance (s tin trong ti
khon)
I. Backend
To bng database (sql/simpleaffiliate_setup/mysql4-install-0.1.0.php)
Bng simpleaffiliate_banner gm cc field sau:
banner_id: Id banner (int(11) unsigned)
title: (varchar 255)
image: ng dn n file nh ca banner (varchar 255)
url: (varchar 255)
status: Disable/ Enable (tinyint(1))
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)
fristname: (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))
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))
1. Manage Banners
To Model/ Resource Model/ Collection thao tc vi bng banner
Thm menu: Simple Affiliate/ Manage Banners
1.1 Listing Banners
To block hin th danh sch cc banner
Block/Adminhtml/Banner.php
Block/Adminhtml/Banner/Grid.php
Hin th danh sch cc banner, d liu cn hin th nh sau:
ID: Id banner (int(11) unsigned)
Image: nh ca banner (show size nh)
Title: (varchar 255)
Url: (varchar 255)
Status: Disable/ Enable (tinyint(1))
Bng d liu sample
ID mage Title Url Status
1 Cellphones off 30% http://store.com/cellphone Enable
-
2 New iPad http://store.com/ipad Disable
Cc action c th thc hin trn trang listing
Add Banner: Thm banner
Search: Tm kim banner theo ID, Title, Url, Status
Edit Banner: Sa thng tin banner
Mass delete: Xa thng tin nhiu banner cng lc
Change Status: Thay i trng thi nhiu banner cng lc
Export d liu banner ra Csv/Xml file
1.2 Add Banner
To cc block show form nhp thng tin banner
Block/Adminhtml/Banner/Edit.php
Block/Adminhtml/Banner/Edit/Form.php
Block/Adminhtml/Banner/Edit/Tabs.php
Block/Adminhtml/Banner/Edit/Tab/Form.php
Cc tabs:
General Information: cha form hin th thng tin banner
1.2.1 General Information:
Form hin th thng tin bao gm cc trng sau:
Title: Text (varchar 255)
-
Image: file upload (varchar 255)
Url: text (varchar 255)
Status: dropdown (Disable/ Enable)
Description: textarea (text)
1.3 Edit Banner
Cc tabs:
General Information: cha form hin th thng tin banner
1.3.1 Tab General Information:
Form hin th thng tin bao gm cc trng sau
Title: Text (varchar 255)
Image: file upload (varchar 255)
Url: text (varchar 255)
Status: dropdown (Disable/ Enable)
Description: textarea (text)
2. Manage Accounts
To Model/ Resource Model/ Collection thao tc vi bng account
Thm menu: Simple Affiliate/ Manage Accounts
1.1 Listing Accounts
To block hin th danh sch account
Block/Adminhtml/Account.php
-
Block/Adminhtml/Account/Grid.php
Hin th danh sch account, d liu cn hin th nh sau:
ID: Account ID (int (11), unsigned)
First Name:
Last Name:
Email: Customer Email (varchar(255))
Balance: s tin trong ti khon (decimal(12,4))
Total Received: tng s commission nhn c (decimal(12,4))
Joined: ngy to account (Datetime)
Status: Disable/ Enable (tinyint(1))
Bng d liu sample
ID Name Email Balance Total
Received
Joined Status
1 Simon
Smaluhn
[email protected] $120 $1649 10/19/12 Enable
2 Matthew
Nutter
[email protected] $50 $785 10/1/12 Enable
Cc action c th thc hin trn trang listing
Add Affiliate account: Thm affiliate account
Search: Tm kim affiliate theo ID, Name, Email, Balance, Total Received, Status
Edit Account: Sa thng tin account
Mass delete : Xa thng tin nhiu account cng lc
Change Status: Thay i trng thi nhiu account cng lc
Export d liu account ra Csv/Xml file
-
1.2 Add Account
To cc block show form nhp thng tin banner
Block/Adminhtml/Account/Edit.php
Block/Adminhtml/Account /Edit/Form.php
Block/Adminhtml/Account /Edit/Tabs.php
Block/Adminhtml/Account /Edit/Tab/Form.php
Cc tabs:
General Information: cha form hin th thng tin account
1.2.1 General Information:
Form hin th thng tin bao gm cc trng sau:
Customer: customer account ca affiliate (dropdown cha danh sch cc customer ca h
thng)
Status: Disable/ Enable
Sau khi chn customer account v status ri click button Save, thng tin ca customer account s
c a vo affiliate account (first name, last name, email) ri lu vo database.
1.3 Edit Affiliate Account
Cc tabs:
General Information: cha form hin th thng tin account
1.3.1 Tab General Information:
-
Form hin th thng tin bao gm cc trng sau
Customer: customer account ca affiliate (dropdown cha danh sch cc customer ca h
thng)
First Name:
Last Name:
Email: Email ca affiliate account
Balance: s tin trong ti khon, show di dng text (not editable)
Total Received: tng s tin affiliate nhn c, show di dng text (not editable)
Joined: ngy to account
Status: Enable/ Disable
Sau khi save, thng tin c cp nht vo affiliate account v customer account ca h thng
3. Manage Transactions
To Model/ Resource Model/ Collection thao tc vi bng transaction
Thm menu: Simple Affiliate/ Manage Transactions
3.1 Listing Transaction
To block hin th danh sch account
Block/Adminhtml/Transaction.php
Block/Adminhtml/Transaction /Grid.php
Hin th danh sch cc transaction (order m cc affiliates gii thiu c), d liu cn hin th
ID
Order ID
Affiliate Email
Order Total
Commission
-
Store
Created
Status
Cc action c th thc hin trn trang listing
Search: Tm kim affiliate theo ID, Order Id, Affiliate Email, Order Total, Commission,
Store, Created, Status
Export d liu transaction ra Csv/Xml file
II. Frontend
2.1 Affiliate Account page
Thm menu Affiliates vo page My Account
Hin th thng tin c nhn ca affiliate:
Name: Tn (Firstname + Lastname)
Balance: S tin trong ti khon
Total Received: tng s tin commission nhn c
Form edit thng tin: First Name, Last Name, Email. Click nt Save s lu thng tin vo
database thng qua model Simpleaffiliate/Account v Customer/Customer. Hin th
thng bo li/ thnh cng
-
2.2 My Banners page
Thm menu Affiliate Banners vo page My Account
Show ton b cc banner c status l enable
Mi banner cn show title, image, HTML code ngi dng c th copy/paste ln cc
forum, blog.
Link ca banner cn c tham s aff, vi gi tr l ID ca affiliate account.
-
2.3 My Transactions Page
Thm menu Affiliate Transaction vo page My Account
Show ton b cc transaction ca affiliate hin ti
Mi banner cn show ID, Date, Order ID, Order Total, Commission, Status
Cn c phn trang (pager) cho danh sch transaction
III. Configuration
Xem phn config trong menu Simple Affiliate/ Settings trong back-end
Cn thm cc config sau:
Enable: bt/ tt module, dropdown (Yes/No)
Commission type: dropdown (Fixed/ Percent)
Commission value: text
Discount type: dropdown (Fixed/ Percent)
Discount value: text
-
IV. Email
Gi email cho khch hng sau khi click nt Signup to Affiliate System
Thm email template
Thm option la chn email template trong phn configuration: Simple Affiliate/ Settings
Gi hm gi email khi create affiliate account frontend
-
V. Event & Override
1. Kim tra thng tin Affiliate trn ng link n website
S dng event controller_action_predispatch kim tra thng tin affiliate t link m khch
hng click n website (www.giaytot.com/cellphones.html?aff=9). Trong , gi tr 9 l ID ca
affiliate account.
Lu thng tin ny vo cookie ca trnh duyt bng cch s dng model core/cookie ca
Magento.
2. To gim gi cho cc sn phm
Thc hin 2 cch to gim gi cho sn phm nh sau:
Cch 1: s dng tnh nng rewrite ca Magento (hn ch ti a vic s dng cch ny)
Rewrite model Mage_Catalog_Model_Product_Type_Price, function getFinalPrice()
Cch 2: s dng cc event ca Magento
catalog_product_get_final_price (gim gi trn trang view detail sn phm)
catalog_block_product_list_collection (gim gi trn trang listing sn phm)
Yu cu: Kim tra thng tin affiliate t cookie ca trnh duyt. Nu c thng tin ID affiliate th
tnh gim gi cho sn phm. Ri set final price cho sn phm bng gi gim.
-
VI. EAV Attribute Product
S dng code thm 4 thuc tnh cho product:
affiliate_commission_type: c kiu l dropdown (2 la chn Fixed/ Percent)
affiliate_commission: (decimal) input text
affiliate_discount_type: c kiu l dropdown (2 la chn Fixed/ Percent)
affiliate_discount: (decimal) input text
Nhng product c set gi tr affiliate_commission hoc affiliate_discount th gi tr discount
v commission tnh theo gi tr ca 2 thuc tnh ny (thay v tnh theo gi tr trong
configuration).
-
VII. Checkout
Chuyn t discount trn Product thnh discount trn shopping cart/ order (s khng tr trc tip
vo gi ca sn phm na).
Thm hai trng lu tr discount cho mt order
affiliate_discount (decimal)
base_affiliate_discount (decimal)
Thm affiliate total add discount vo shopping cart total
Hin th, x l total ca order trong Admin, Frontend, Email (View Order, Invoice, CreditMemo,
print PDF)
- view order in backend
S dng event sales_order_place_after to transaction sau khi 1 order c to bi KH
click vo link affiliate. Status ca transaction c to ra ph thuc vo status ca order (order
completed trasaction completed, cc status khc ca order transaction pending)
-
S dng event sales_order_save_after kim tra xem status ca order c phi l complete hay
ko (order c thanh ton tin). Nu status order l complete, chuyn status ca transaction
tng ng thnh complete. ng thi, chuyn s commission trong trasnaction vo balance ca
affiliate tng ng.