/** * Limit customer segment save * * @param Enterprise_CustomerSegment_Model_Segment $model * @return void */ public function customerSegmentSaveBefore($model) { if (!$model->getId() && !$this->_role->getIsWebsiteLevel()) { $this->_throwSave(); } if ($model->getId() && !$this->_role->hasExclusiveAccess($model->getWebsiteIds())) { $this->_throwSave(); } }
/** * Save customer Ids matched by segment SQL select * * @deprecate after 1.6.0.0 - please use $this->saveCustomersFromSelect() instead * * @param Enterprise_CustomerSegment_Model_Segment $segment * @param Varien_Db_Select $select * @return Enterprise_CustomerSegment_Model_Resource_Segment */ public function saveSegmentCustomersFromSelect($segment, $select) { $table = $this->getTable('enterprise_customersegment/customer'); $adapter = $this->_getWriteAdapter(); $segmentId = $segment->getId(); $now = $this->formatDate(time()); $adapter->delete($table, $adapter->quoteInto('segment_id=?', $segmentId)); $data = array(); $count = 0; $stmt = $adapter->query($select); while ($row = $stmt->fetch()) { $data[] = array('segment_id' => $segmentId, 'customer_id' => $row['entity_id'], 'added_date' => $now, 'updated_date' => $now); $count++; if ($count > 1000) { $count = 0; $adapter->insertMultiple($table, $data); $data = array(); } } if ($count > 0) { $adapter->insertMultiple($table, $data); } return $this; }
/** * Return url for current row * * @param Enterprise_CustomerSegment_Model_Segment $row * @return string */ public function getRowUrl($row) { return $this->getUrl('*/*/detail', array('segment_id' => $row->getId())); }