本文整理汇总了PHP中Magento\Framework\Model\AbstractModel::getProductId方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractModel::getProductId方法的具体用法?PHP AbstractModel::getProductId怎么用?PHP AbstractModel::getProductId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Model\AbstractModel
的用法示例。
在下文中一共展示了AbstractModel::getProductId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: validate
/**
* Validate Product Rule Condition
*
* @param \Magento\Framework\Model\AbstractModel $model
* @return bool
*/
public function validate(\Magento\Framework\Model\AbstractModel $model)
{
//@todo reimplement this method when is fixed MAGETWO-5713
/** @var \Magento\Catalog\Model\Product $product */
$product = $model->getProduct();
if (!$product instanceof \Magento\Catalog\Model\Product) {
$product = $this->productRepository->getById($model->getProductId());
}
$product->setQuoteItemQty($model->getQty())->setQuoteItemPrice($model->getPrice())->setQuoteItemRowTotal($model->getBaseRowTotal());
return parent::validate($product);
}
示例3: _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);
}