Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AbstractResource.php
Go to the documentation of this file.
1 <?php
7 
14 {
21  protected function _getAlertRow(\Magento\Framework\Model\AbstractModel $object)
22  {
23  $connection = $this->getConnection();
24  if ($object->getCustomerId() && $object->getProductId() && $object->getWebsiteId()) {
25  $select = $connection->select()->from(
26  $this->getMainTable()
27  )->where(
28  'customer_id = :customer_id'
29  )->where(
30  'product_id = :product_id'
31  )->where(
32  'website_id = :website_id'
33  );
34  $bind = [
35  ':customer_id' => $object->getCustomerId(),
36  ':product_id' => $object->getProductId(),
37  ':website_id' => $object->getWebsiteId(),
38  ];
39  return $connection->fetchRow($select, $bind);
40  }
41  return false;
42  }
43 
50  public function loadByParam(\Magento\Framework\Model\AbstractModel $object)
51  {
52  $row = $this->_getAlertRow($object);
53  if ($row) {
54  $object->setData($row);
55  }
56  return $this;
57  }
58 
68  public function deleteCustomer(\Magento\Framework\Model\AbstractModel $object, $customerId, $websiteId = null)
69  {
70  $connection = $this->getConnection();
71  $where = [];
72  $where[] = $connection->quoteInto('customer_id=?', $customerId);
73  if ($websiteId) {
74  $where[] = $connection->quoteInto('website_id=?', $websiteId);
75  }
76  $connection->delete($this->getMainTable(), $where);
77  return $this;
78  }
79 }
_getAlertRow(\Magento\Framework\Model\AbstractModel $object)
deleteCustomer(\Magento\Framework\Model\AbstractModel $object, $customerId, $websiteId=null)
loadByParam(\Magento\Framework\Model\AbstractModel $object)
$connection
Definition: bulk.php:13