47 $this->resolveDate($object,
'from_date');
48 $this->resolveDate($object,
'to_date');
49 parent::_beforeSave($object);
60 $date = $object->getData($dateIdentifier);
61 if ($date instanceof \DateTimeInterface) {
62 $object->setData($dateIdentifier, $date->format(
'Y-m-d H:i:s'));
63 }
elseif (!is_string($date) || empty($date)) {
64 $object->setData($dateIdentifier,
null);
83 }
catch (\Exception $e) {
103 if (empty($ruleIds) || empty($entityIds)) {
106 if (!is_array($ruleIds)) {
107 $ruleIds = [(int)$ruleIds];
109 if (!is_array($entityIds)) {
110 $entityIds = [(int)$entityIds];
115 foreach ($ruleIds as
$ruleId) {
116 foreach ($entityIds as $entityId) {
118 $entityInfo[
'entity_id_field'] => $entityId,
119 $entityInfo[
'rule_id_field'] =>
$ruleId,
124 $this->
getTable($entityInfo[
'associations_table']),
126 [$entityInfo[
'rule_id_field']]
134 $this->
getTable($entityInfo[
'associations_table']),
136 [$entityInfo[
'rule_id_field']]
141 $this->
getTable($entityInfo[
'associations_table']),
143 $entityInfo[
'rule_id_field'] .
' IN (?) AND ',
146 $entityInfo[
'entity_id_field'] .
' NOT IN (?)',
166 if (!is_array($entityIds)) {
167 $entityIds = [(int)$entityIds];
169 if (!is_array($ruleIds)) {
170 $ruleIds = [(int)$ruleIds];
174 if (!empty($ruleIds)) {
175 $where[] =
$connection->quoteInto($entityInfo[
'rule_id_field'] .
' IN (?)', $ruleIds);
177 if (!empty($entityIds)) {
178 $where[] =
$connection->quoteInto($entityInfo[
'entity_id_field'] .
' IN (?)', $entityIds);
181 $connection->delete($this->
getTable($entityInfo[
'associations_table']), implode(
' AND ', $where));
198 $this->
getTable($entityInfo[
'associations_table']),
199 [$entityInfo[
'entity_id_field']]
201 $entityInfo[
'rule_id_field'] .
' = ?',
240 if (isset($this->_associatedEntitiesMap[
$entityType])) {
244 throw new \Magento\Framework\Exception\LocalizedException(
245 __(
'There is no information about associated entity type "%1".',
$entityType)
elseif(isset( $params[ 'redirect_parent']))
_getAssociatedEntityInfo($entityType)
getCustomerGroupIds($ruleId)
_beforeSave(\Magento\Framework\Model\AbstractModel $object)
unbindRuleFromEntity($ruleIds, $entityIds, $entityType)
getAssociatedEntityIds($ruleId, $entityType)
_multiplyBunchInsert($ruleIds, $entityIds, $entityType)
bindRuleToEntity($ruleIds, $entityIds, $entityType)