Skip to content

Commit a703c8a

Browse files
authored
Add checkout agreement position, closes #1288 (#1480)
1 parent 7526749 commit a703c8a

File tree

5 files changed

+96
-5
lines changed

5 files changed

+96
-5
lines changed

app/code/core/Mage/Adminhtml/Block/Checkout/Agreement/Edit/Form.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ protected function _prepareForm()
133133
'title' => Mage::helper('checkout')->__('Content'),
134134
'style' => 'height:24em;',
135135
'wysiwyg' => false,
136-
'required' => true,
136+
'required' => false,
137137
));
138138

139139
$fieldset->addField('content_height', 'text', array(
@@ -144,6 +144,15 @@ protected function _prepareForm()
144144
'class' => 'validate-css-length',
145145
));
146146

147+
$fieldset->addField('position', 'text', array(
148+
'label' => Mage::helper('checkout')->__('Position'),
149+
'title' => Mage::helper('checkout')->__('Position'),
150+
'name' => 'position',
151+
'value' => '0',
152+
'required' => true,
153+
'class' => 'validate-digits',
154+
));
155+
147156
$form->setValues($model->getData());
148157
$form->setUseContainer(true);
149158
$this->setForm($form);

app/code/core/Mage/Adminhtml/Block/Checkout/Agreement/Grid.php

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,17 @@
2323
* @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com)
2424
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
2525
*/
26+
27+
/**
28+
* Class Mage_Adminhtml_Block_Checkout_Agreement_Grid
29+
*
30+
* @method Mage_Checkout_Model_Resource_Agreement_Collection getCollection()
31+
*/
2632
class Mage_Adminhtml_Block_Checkout_Agreement_Grid extends Mage_Adminhtml_Block_Widget_Grid
2733
{
28-
34+
/**
35+
* Mage_Adminhtml_Block_Checkout_Agreement_Grid constructor.
36+
*/
2937
public function __construct()
3038
{
3139
parent::__construct();
@@ -35,6 +43,9 @@ public function __construct()
3543
$this->setSaveParametersInSession(true);
3644
}
3745

46+
/**
47+
* @inheritDoc
48+
*/
3849
protected function _prepareCollection()
3950
{
4051
$collection = Mage::getModel('checkout/agreement')
@@ -43,6 +54,9 @@ protected function _prepareCollection()
4354
return parent::_prepareCollection();
4455
}
4556

57+
/**
58+
* @inheritDoc
59+
*/
4660
protected function _prepareColumns()
4761
{
4862
$this->addColumn('agreement_id',
@@ -54,6 +68,14 @@ protected function _prepareColumns()
5468
)
5569
);
5670

71+
$this->addColumn('position', array(
72+
'header' => Mage::helper('adminhtml')->__('Position'),
73+
'align' =>'right',
74+
'width' => '50px',
75+
'index' => 'position',
76+
'type' => 'text',
77+
));
78+
5779
$this->addColumn('name',
5880
array(
5981
'header'=>Mage::helper('checkout')->__('Condition Name'),
@@ -87,12 +109,19 @@ protected function _prepareColumns()
87109
return parent::_prepareColumns();
88110
}
89111

112+
/**
113+
* @return void
114+
*/
90115
protected function _afterLoadCollection()
91116
{
92117
$this->getCollection()->walk('afterLoad');
93118
parent::_afterLoadCollection();
94119
}
95120

121+
/**
122+
* @param $collection
123+
* @param Mage_Adminhtml_Block_Widget_Grid_Column $column
124+
*/
96125
protected function _filterStoreCondition($collection, $column)
97126
{
98127
if (!$value = $column->getFilter()->getValue()) {
@@ -102,9 +131,12 @@ protected function _filterStoreCondition($collection, $column)
102131
$this->getCollection()->addStoreFilter($value);
103132
}
104133

134+
/**
135+
* @param Mage_Checkout_Model_Agreement $row
136+
* @return string
137+
*/
105138
public function getRowUrl($row)
106139
{
107140
return $this->getUrl('*/*/edit', array('id' => $row->getId()));
108141
}
109-
110142
}

app/code/core/Mage/Checkout/Block/Agreements.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ public function getAgreements()
4444
} else {
4545
$agreements = Mage::getModel('checkout/agreement')->getCollection()
4646
->addStoreFilter(Mage::app()->getStore()->getId())
47-
->addFieldToFilter('is_active', 1);
47+
->addFieldToFilter('is_active', 1)
48+
->setOrder('position', Varien_Data_Collection::SORT_ORDER_ASC);
4849
}
4950
$this->setAgreements($agreements);
5051
}

app/code/core/Mage/Checkout/etc/config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<config>
2929
<modules>
3030
<Mage_Checkout>
31-
<version>1.6.0.0</version>
31+
<version>1.6.0.1</version>
3232
</Mage_Checkout>
3333
</modules>
3434
<global>
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
/**
3+
* Magento
4+
*
5+
* NOTICE OF LICENSE
6+
*
7+
* This source file is subject to the Open Software License (OSL 3.0)
8+
* that is bundled with this package in the file LICENSE.txt.
9+
* It is also available through the world-wide-web at this URL:
10+
* http://opensource.org/licenses/osl-3.0.php
11+
* If you did not receive a copy of the license and are unable to
12+
* obtain it through the world-wide-web, please send an email
13+
* to license@magento.com so we can send you a copy immediately.
14+
*
15+
* DISCLAIMER
16+
*
17+
* Do not edit or add to this file if you wish to upgrade Magento to newer
18+
* versions in the future. If you wish to customize Magento for your
19+
* needs please refer to http://www.magento.com for more information.
20+
*
21+
* @category Mage
22+
* @package Mage_Checkout
23+
* @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com)
24+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25+
*/
26+
27+
/* @var Mage_Core_Model_Resource_Setup $installer */
28+
$installer = $this;
29+
$installer->startSetup();
30+
31+
$connection = $installer->getConnection();
32+
$table = $installer->getTable('checkout/agreement');
33+
$column = 'position';
34+
35+
if (!$connection->tableColumnExists($table, $column)) {
36+
$connection->addColumn(
37+
$table,
38+
$column,
39+
array(
40+
'type' => Varien_Db_Ddl_Table::TYPE_SMALLINT,
41+
'length' => 2,
42+
'nullable' => false,
43+
'default' => 0,
44+
'comment' => 'Agreement Position'
45+
)
46+
);
47+
}
48+
49+
$installer->endSetup();

0 commit comments

Comments
 (0)