Example #1
0
 /**
  * Renders grid column
  *
  * @param \Magento\Framework\DataObject $row
  * @return \Magento\Framework\Phrase|string
  */
 public function render(\Magento\Framework\DataObject $row)
 {
     $id = $row->getCustomerId();
     if (!$id) {
         return __('Show Reviews');
     }
     return sprintf('<a href="%s">%s</a>', $this->getUrl('review/product/', ['customerId' => $id]), __('Show Reviews'));
 }
Example #2
0
 /**
  * Render review type
  *
  * @param \Magento\Framework\DataObject $row
  * @return \Magento\Framework\Phrase
  */
 public function render(\Magento\Framework\DataObject $row)
 {
     if ($row->getCustomerId()) {
         return __('Customer');
     }
     if ($row->getStoreId() == \Magento\Store\Model\Store::DEFAULT_STORE_ID) {
         return __('Administrator');
     }
     return __('Guest');
 }
Example #3
0
 /**
  * {@inheritdoc}
  */
 protected function _afterDelete(\Magento\Framework\DataObject $address)
 {
     if ($address->getId()) {
         $customer = $this->customerRepository->getById($address->getCustomerId());
         if ($customer->getDefaultBilling() == $address->getId()) {
             $customer->setDefaultBilling(null);
         }
         if ($customer->getDefaultShipping() == $address->getId()) {
             $customer->setDefaultShipping(null);
         }
         $this->customerRepository->save($customer);
     }
     return parent::_afterDelete($address);
 }
Example #4
0
 /**
  * @param \Magento\Framework\DataObject $row
  *
  * @return string
  */
 public function getRowUrl($row)
 {
     return $this->getUrl('customer/index/edit', ['id' => $row->getCustomerId(), 'active_tab' => 'cart']);
 }
 /**
  * Add information about product ids to visitor/customer
  *
  * @param \Magento\Framework\DataObject|\Magento\Reports\Model\Product\Index\AbstractIndex $object
  * @param int[] $productIds
  * @return $this
  */
 public function registerIds(\Magento\Framework\DataObject $object, $productIds)
 {
     $row = ['visitor_id' => $object->getVisitorId(), 'customer_id' => $object->getCustomerId(), 'store_id' => $object->getStoreId()];
     $data = [];
     foreach ($productIds as $productId) {
         $productId = (int) $productId;
         if ($productId) {
             $row['product_id'] = $productId;
             $data[] = $row;
         }
     }
     $matchFields = ['product_id', 'store_id'];
     foreach ($data as $row) {
         $this->_resourceHelper->mergeVisitorProductIndex($this->getMainTable(), $row, $matchFields);
     }
     return $this;
 }
 /**
  * Add information about product ids to visitor/customer
  *
  * @param \Magento\Framework\DataObject|\Magento\Reports\Model\Product\Index\AbstractIndex $object
  * @param int[] $productIds
  * @return $this
  */
 public function registerIds(\Magento\Framework\DataObject $object, $productIds)
 {
     $row = ['visitor_id' => $object->getVisitorId(), 'customer_id' => $object->getCustomerId(), 'store_id' => $object->getStoreId()];
     $addedAt = (new \DateTime())->getTimestamp();
     $data = [];
     foreach ($productIds as $productId) {
         $productId = (int) $productId;
         if ($productId) {
             $row['product_id'] = $productId;
             $row['added_at'] = $this->dateTime->formatDate($addedAt);
             $data[] = $row;
         }
         $addedAt -= $addedAt > 0 ? 1 : 0;
     }
     $matchFields = ['product_id', 'store_id'];
     foreach ($data as $row) {
         $this->_resourceHelper->mergeVisitorProductIndex($this->getMainTable(), $row, $matchFields);
     }
     return $this;
 }