7
7
namespace Magento \SalesRule \Model \ResourceModel \Rule ;
8
8
9
9
use Magento \Framework \DB \Select ;
10
+ use Magento \Framework \EntityManager \MetadataPool ;
10
11
use Magento \Framework \Model \AbstractExtensibleModel ;
11
12
use Magento \Framework \Serialize \Serializer \Json ;
12
13
use Magento \Quote \Model \Quote \Address ;
13
14
use Magento \SalesRule \Api \Data \CouponInterface ;
15
+ use Magento \SalesRule \Api \Data \RuleInterface ;
16
+ use Magento \SalesRule \Api \Data \RuleInterfaceFactory ;
14
17
use Magento \SalesRule \Model \Coupon ;
15
18
use Magento \SalesRule \Model \Rule ;
16
19
@@ -60,6 +63,11 @@ class Collection extends \Magento\Rule\Model\ResourceModel\Rule\Collection\Abstr
60
63
*/
61
64
private $ serializer ;
62
65
66
+ /**
67
+ * @var MetadataPool $metadataPool
68
+ */
69
+ private $ metadataPool ;
70
+
63
71
/**
64
72
* @param \Magento\Framework\Data\Collection\EntityFactory $entityFactory
65
73
* @param \Psr\Log\LoggerInterface $logger
@@ -78,13 +86,14 @@ public function __construct(
78
86
\Magento \Framework \Stdlib \DateTime \TimezoneInterface $ date ,
79
87
\Magento \Framework \DB \Adapter \AdapterInterface $ connection = null ,
80
88
\Magento \Framework \Model \ResourceModel \Db \AbstractDb $ resource = null ,
81
- Json $ serializer = null
89
+ Json $ serializer = null ,
90
+ MetadataPool $ metadataPool = null ,
82
91
) {
83
92
parent ::__construct ($ entityFactory , $ logger , $ fetchStrategy , $ eventManager , $ connection , $ resource );
84
93
$ this ->_date = $ date ;
85
94
$ this ->serializer = $ serializer ?: \Magento \Framework \App \ObjectManager::getInstance ()->get (Json::class);
86
95
$ this ->_associatedEntitiesMap = $ this ->getAssociatedEntitiesMap ();
87
- $ this ->_setIdFieldName (' row_id ' );
96
+ $ this ->_setIdFieldName ($ this -> metadataPool -> getMetadata (RuleInterface::class)-> getLinkField () );
88
97
}
89
98
90
99
/**
0 commit comments