Thứ Ba, 23 tháng 9, 2014

Overriding Magento Controller

Overriding Magento Controller


---o0o---


Note: Controller chứ không phải controllers

Cần phân biệt 2 thư mục controllers và Controller trong Magento Module. Với controllers ta rewrite theo cách thông thường. Còn với Controller ta rewrite theo cách sau

Ví dụ cụ thể: Bỏ bước review khi checkout bằng Paypal

Để bỏ qua bước review cần sửa code ở 2 file sau

File thứ 1:


        \app\code\core\Mage\Paypal\Controller\Express\Abstract.php
        

Tìm tới hàm:


        returnAction()
        

Tìm tới dòng:


        $this->_redirect('*/*/review');
        

Sửa dòng này thành:


        $this->_redirect('*/*/placeOrder');
        

File thứ 2:


        \app\code\core\Mage\Paypal\Model\Config.php
        

Tìm tới hàm: getExpressCheckoutStartUrl()


        public function getExpressCheckoutStartUrl($token)
        {
            return $this->getPaypalUrl(array(
                'cmd'   => '_express-checkout',
                'token' => $token,
            ));
        }
        

Sửa hàm này thành:


        public function getExpressCheckoutStartUrl($token)
        {
            return $this->getPaypalUrl(array(
                'cmd'   => '_express-checkout',
                'useraction' => 'commit',
                'token' => $token,
            ));
        }
        

Vậy là ta đã biết cần sửa ở đâu, nhưng không thể vào trong core sửa được nên cần có bước rewrite

Bạn chỉ cần copy 2 file ra thư mục local/Mage và sửa như trên

Nghĩa là, ta tạo ra 2 file mới


            /app/code/local/Mage/Paypal/Controller/Express/Abstract.php
            /app/code/local/Mage/Paypal/Model/Config.php
        

Done!

Thứ Hai, 22 tháng 9, 2014

HTML QUIZ - W3School

HTML QUIZ


---o0o---


1. Q: What does HTML stand for?

A: Hyper Text Markup Language

2. Q: Who is making the Web standards?

A: The World Wide Web Consortium

3. Q: Choose the correct HTML tag for the largest heading

A: <h1>

4. Q: What is the correct HTML tag for inserting a line break?

A: <br>

5. Q: What is the preferred way for adding a background color in HTML?

A: <body style="background-color:yellow;">

6. Q: Choose the correct HTML tag to make a text bold

A: <b>

7. Q: Choose the correct HTML tag to make a text italic

A: <i>

8. Q: What is the correct HTML for creating a hyperlink?

A: <a href="http://www.w3schools.com">W3Schools</a>

9. Q: How can you create an e-mail link?

A: <a href="mailto:xxx@yyy">

10. Q: How can you open a link in a new tab/browser window?

A: <a href="url" target="_blank">

11. Q: Which of these tags are all <table> tags?

A: <table><tr><td>

12. Q: In HTML, inline elements are normally displayed without starting a new line.

A: TRUE

13. Q: How can you make a numbered list?

A: <ol>

14. Q: How can you make a bulleted list?

A: <ul>

15. Q: What is the correct HTML for making a checkbox?

A: <input type="checkbox">

16. Q: What is the correct HTML for making a text input field?

A: <input type="text">

17. Q: What is the correct HTML for making a drop-down list?

A: <select>

18. Q: What is the correct HTML for making a text area?

A: <textarea>

19. Q: What is the correct HTML for inserting an image?

A: <img src="image.gif" alt="MyImage">

20. Q: What is the correct HTML for inserting a background image?

A: <body background="background.gif">

Chủ Nhật, 21 tháng 9, 2014

SQL Quiz - W3School

SQL Quiz - W3School


---o0o---


1. Q: What does SQL stand for?

A: Structured Query Language

2. Q: Which SQL statement is used to extract data from a database?

A: SELECT

3. Q: Which SQL statement is used to update data in a database?

A: UPDATE

4. Q: Which SQL statement is used to delete data from a database?

A: DELETE

5. Q: Which SQL statement is used to insert new data in a database?

A: INSERT INTO

6. Q: With SQL, how do you select a column named "FirstName" from a table named "Persons"?

A: SELECT FirstName FROM Persons

7. Q: With SQL, how do you select all the columns from a table named "Persons"?

A: SELECT * FROM Persons

8. Q: With SQL, how do you select all the records from a table named "Persons" where the value of the column "FirstName" is "Peter"?

A: SELECT * FROM Persons WHERE FirstName='Peter'

9. Q: With SQL, how do you select all the records from a table named "Persons" where the value of the column "FirstName" starts with an "a"?

A: SELECT * FROM Persons WHERE FirstName LIKE 'a%'

10. Q: The OR operator displays a record if ANY conditions listed are true. The AND operator displays a record if ALL of the conditions listed are true

A: True

11. Q: With SQL, how do you select all the records from a table named "Persons" where the "FirstName" is "Peter" and the "LastName" is "Jackson"?

A: SELECT * FROM Persons WHERE FirstName='Peter' AND LastName='Jackson'

12. Q: With SQL, how do you select all the records from a table named "Persons" where the "LastName" is alphabetically between (and including) "Hansen" and "Pettersen"?

A: SELECT * FROM Persons WHERE LastName BETWEEN 'Hansen' AND 'Pettersen'

13. Q: Which SQL statement is used to return only different values?

A: SELECT UNIQUE

14. Q: Which SQL keyword is used to sort the result-set?

A: ORDER BY

15. Q: With SQL, how can you return all the records from a table named "Persons" sorted descending by "FirstName"?

A: SELECT * FROM Persons ORDER BY FirstName DESC

16. Q: With SQL, how can you insert a new record into the "Persons" table?

A: INSERT INTO Persons VALUES ('Jimmy', 'Jackson')

17. Q: With SQL, how can you insert "Olsen" as the "LastName" in the "Persons" table?

A: INSERT INTO Persons (LastName) VALUES ('Olsen')

18. Q: How can you change "Hansen" into "Nilsen" in the "LastName" column in the Persons table?

A: UPDATE Persons SET LastName='Nilsen' WHERE LastName='Hansen'

19. Q: With SQL, how can you delete the records where the "FirstName" is "Peter" in the Persons Table?

A: DELETE FROM Persons WHERE FirstName = 'Peter'

20. Q: With SQL, how can you return the number of records in the "Persons" table?

A: SELECT COUNT(*) FROM Persons