本文整理汇总了PHP中Magento\Framework\Model\AbstractModel::getCustomerId方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractModel::getCustomerId方法的具体用法?PHP AbstractModel::getCustomerId怎么用?PHP AbstractModel::getCustomerId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Model\AbstractModel
的用法示例。
在下文中一共展示了AbstractModel::getCustomerId方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _getAlertRow
/**
* Retrieve alert row by object parameters
*
* @param \Magento\Framework\Model\AbstractModel $object
* @return array|false
*/
protected function _getAlertRow(\Magento\Framework\Model\AbstractModel $object)
{
$adapter = $this->_getReadAdapter();
if ($object->getCustomerId() && $object->getProductId() && $object->getWebsiteId()) {
$select = $adapter->select()->from($this->getMainTable())->where('customer_id = :customer_id')->where('product_id = :product_id')->where('website_id = :website_id');
$bind = [':customer_id' => $object->getCustomerId(), ':product_id' => $object->getProductId(), ':website_id' => $object->getWebsiteId()];
return $adapter->fetchRow($select, $bind);
}
return false;
}
示例2: _beforeSave
/**
* Before save action
*
* @param \Magento\Framework\Model\AbstractModel $object
* @return $this
*/
protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
{
if (is_null($object->getId()) && $object->getCustomerId() && $object->getProductId() && $object->getWebsiteId()) {
if ($row = $this->_getAlertRow($object)) {
$object->addData($row);
$object->setStatus(0);
}
}
if (is_null($object->getAddDate())) {
$object->setAddDate($this->_dateFactory->create()->gmtDate());
$object->setStatus(0);
}
return parent::_beforeSave($object);
}
示例3: _afterSave
/**
* Perform actions after object save
*
* @param \Magento\Framework\Model\AbstractModel $object
* @return $this
*/
protected function _afterSave(AbstractModel $object)
{
$adapter = $this->_getWriteAdapter();
/**
* save detail
*/
$detail = ['title' => $object->getTitle(), 'detail' => $object->getDetail(), 'nickname' => $object->getNickname()];
$select = $adapter->select()->from($this->_reviewDetailTable, 'detail_id')->where('review_id = :review_id');
$detailId = $adapter->fetchOne($select, [':review_id' => $object->getId()]);
if ($detailId) {
$condition = ["detail_id = ?" => $detailId];
$adapter->update($this->_reviewDetailTable, $detail, $condition);
} else {
$detail['store_id'] = $object->getStoreId();
$detail['customer_id'] = $object->getCustomerId();
$detail['review_id'] = $object->getId();
$adapter->insert($this->_reviewDetailTable, $detail);
}
/**
* save stores
*/
$stores = $object->getStores();
if (!empty($stores)) {
$condition = ['review_id = ?' => $object->getId()];
$adapter->delete($this->_reviewStoreTable, $condition);
$insertedStoreIds = [];
foreach ($stores as $storeId) {
if (in_array($storeId, $insertedStoreIds)) {
continue;
}
$insertedStoreIds[] = $storeId;
$storeInsert = ['store_id' => $storeId, 'review_id' => $object->getId()];
$adapter->insert($this->_reviewStoreTable, $storeInsert);
}
}
// reaggregate ratings, that depend on this review
$this->_aggregateRatings($this->_loadVotedRatingIds($object->getId()), $object->getEntityPkValue());
return $this;
}
示例4: _prepareDataForSave
/**
* Prepare data for save
*
* @param \Magento\Framework\Model\AbstractModel $visitor
* @return array
*/
protected function _prepareDataForSave(\Magento\Framework\Model\AbstractModel $visitor)
{
return ['customer_id' => $visitor->getCustomerId(), 'session_id' => $visitor->getSessionId(), 'last_visit_at' => $visitor->getLastVisitAt()];
}