예제 #1
0
 /**
  * Update customer type after customer login
  *
  * @param int $visitorId
  * @param int $customerId
  * @param array $types
  * @return $this
  */
 public function updateCustomerType($visitorId, $customerId, $types = null)
 {
     if ($types === null) {
         $types = [];
         $typesCollection = $this->_eventTypeFactory->create()->getCollection();
         foreach ($typesCollection as $eventType) {
             if ($eventType->getCustomerLogin()) {
                 $types[$eventType->getId()] = $eventType->getId();
             }
         }
     }
     $this->getResource()->updateCustomerType($this, $visitorId, $customerId, $types);
     return $this;
 }
예제 #2
0
 /**
  * Add views count
  *
  * @param string $from
  * @param string $to
  * @return $this
  */
 public function addViewsCount($from = '', $to = '')
 {
     /**
      * Getting event type id for catalog_product_view event
      */
     $eventTypes = $this->_eventTypeFactory->create()->getCollection();
     foreach ($eventTypes as $eventType) {
         if ($eventType->getEventName() == 'catalog_product_view') {
             $productViewEvent = (int) $eventType->getId();
             break;
         }
     }
     $this->getSelect()->reset()->from(['report_table_views' => $this->getTable('report_event')], ['views' => 'COUNT(report_table_views.event_id)'])->join(['e' => $this->getProductEntityTableName()], $this->getConnection()->quoteInto('e.entity_id = report_table_views.object_id AND e.attribute_set_id = ?', $this->getProductAttributeSetId()))->where('report_table_views.event_type_id = ?', $productViewEvent)->group('e.entity_id')->order('views ' . self::SORT_ORDER_DESC)->having('COUNT(report_table_views.event_id) > ?', 0);
     if ($from != '' && $to != '') {
         $this->getSelect()->where('logged_at >= ?', $from)->where('logged_at <= ?', $to);
     }
     return $this;
 }