Grid::_prepareCollection()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 0
1
<?php
2
3
/**
4
 *
5
 *
6
 * @category Mygento
7
 * @package Mygento_Yandexdelivery
8
 * @copyright 2017 NKS LLC. (http://www.mygento.ru)
9
 * @license GPLv2
10
 */
11
class Mygento_Yandexdelivery_Block_Adminhtml_Shipment_Grid extends Mage_Adminhtml_Block_Widget_Grid
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
12
{
13
14
    public function _construct()
15
    {
16
        parent::_construct();
17
        $this->setId('shipmentGrid');
18
        $this->setDefaultSort('id');
19
        $this->setDefaultDir('ASC');
20
        $this->setSaveParametersInSession(true);
21
    }
22
23
    protected function _prepareCollection()
24
    {
25
        $collection = Mage::getModel('yandexdelivery/shipment')->getCollection();
26
        $collection->getSelect()->join(
27
            array('table_alias' => Mage::getConfig()->getTablePrefix() . 'sales_flat_order'),
28
            'main_table.order_id = table_alias.entity_id',
29
            array('increment_id' => 'table_alias.increment_id')
30
        );
31
        $this->setCollection($collection);
32
        return parent::_prepareCollection();
33
    }
34
35
    protected function _prepareColumns()
36
    {
37
        $this->addColumn('increment_id', array(
38
            'header' => Mage::helper('yandexdelivery')->__('Order ID'),
39
            'align' => 'left',
40
            'index' => 'increment_id',
41
        ));
42
43
        $this->addColumn('yd_id', array(
44
            'header' => Mage::helper('yandexdelivery')->__('Yandex Delivery Id'),
45
            'align' => 'right',
46
            'width' => '30px',
47
            'index' => 'yd_id',
48
        ));
49
50
        return parent::_prepareColumns();
51
    }
52
}
53