-
Notifications
You must be signed in to change notification settings - Fork 9.3k
/
Collection.php
68 lines (61 loc) · 1.51 KB
/
Collection.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Quote\Model\ResourceModel\Quote\Address;
/**
* Quote addresses collection
*
* @author Magento Core Team <core@magentocommerce.com>
*/
class Collection extends \Magento\Framework\Model\ResourceModel\Db\VersionControl\Collection
{
/**
* Event prefix
*
* @var string
*/
protected $_eventPrefix = 'sales_quote_address_collection';
/**
* Event object name
*
* @var string
*/
protected $_eventObject = 'quote_address_collection';
/**
* Resource initialization
*
* @return void
*/
protected function _construct()
{
$this->_init(
\Magento\Quote\Model\Quote\Address::class,
\Magento\Quote\Model\ResourceModel\Quote\Address::class
);
}
/**
* Setting filter on quote_id field but if quote_id is 0
* we should exclude loading junk data from DB
*
* @param int $quoteId
* @return $this
*/
public function setQuoteFilter($quoteId)
{
$this->addFieldToFilter('quote_id', $quoteId ? $quoteId : ['null' => 1]);
return $this;
}
/**
* Redeclare after load method for dispatch event
*
* @return $this
*/
protected function _afterLoad()
{
parent::_afterLoad();
$this->_eventManager->dispatch($this->_eventPrefix . '_load_after', [$this->_eventObject => $this]);
return $this;
}
}