本文整理汇总了PHP中Magento\Framework\Model\AbstractModel::getStores方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractModel::getStores方法的具体用法?PHP AbstractModel::getStores怎么用?PHP AbstractModel::getStores使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Model\AbstractModel
的用法示例。
在下文中一共展示了AbstractModel::getStores方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _afterSave
/**
* Perform operations after object save
*
* @param \Magento\Framework\Model\AbstractModel $object
* @return $this
*/
protected function _afterSave(\Magento\Framework\Model\AbstractModel $object)
{
$oldStores = $this->lookupStoreIds($object->getId());
$newStores = (array) $object->getStores();
$table = $this->getTable('cms_block_store');
$insert = array_diff($newStores, $oldStores);
$delete = array_diff($oldStores, $newStores);
if ($delete) {
$where = ['block_id = ?' => (int) $object->getId(), 'store_id IN (?)' => $delete];
$this->_getWriteAdapter()->delete($table, $where);
}
if ($insert) {
$data = [];
foreach ($insert as $storeId) {
$data[] = ['block_id' => (int) $object->getId(), 'store_id' => (int) $storeId];
}
$this->_getWriteAdapter()->insertMultiple($table, $data);
}
return parent::_afterSave($object);
}
示例2: _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;
}
示例3: processRatingStores
/**
* @param \Magento\Framework\Model\AbstractModel $object
* @return $this
*/
protected function processRatingStores(\Magento\Framework\Model\AbstractModel $object)
{
$adapter = $this->_getWriteAdapter();
$ratingId = (int) $object->getId();
$table = $this->getTable('rating_store');
$select = $adapter->select()->from($table, ['store_id'])->where('rating_id = :rating_id');
$old = $adapter->fetchCol($select, [':rating_id' => $ratingId]);
$new = $object->getStores();
$this->deleteRatingData($ratingId, $table, array_diff_assoc($old, $new));
$insert = [];
foreach (array_keys(array_diff_assoc($new, $old)) as $storeId) {
$insert[] = ['rating_id' => $ratingId, 'store_id' => (int) $storeId];
}
$this->insertRatingData($table, $insert);
return $this;
}
示例4: _afterSave
/**
* Assign post to store views, categories, related posts, etc.
*
* @param \Magento\Framework\Model\AbstractModel $object
* @return $this
*/
protected function _afterSave(\Magento\Framework\Model\AbstractModel $object)
{
$oldIds = $this->lookupStoreIds($object->getId());
$newIds = (array) $object->getStores();
if (empty($newIds)) {
$newIds = (array) $object->getStoreId();
}
$this->_updateLinks($object, $newIds, $oldIds, 'magefan_blog_post_store', 'store_id');
$newIds = (array) $object->getCategories();
if (is_array($newIds)) {
$oldIds = $this->lookupCategoryIds($object->getId());
$this->_updateLinks($object, $newIds, $oldIds, 'magefan_blog_post_category', 'category_id');
}
$newIds = $object->getRelatedPostIds();
if (is_array($newIds)) {
$oldIds = $this->lookupRelatedPostIds($object->getId());
$this->_updateLinks($object, $newIds, $oldIds, 'magefan_blog_post_relatedpost', 'related_id');
}
$newIds = $object->getRelatedProductIds();
if (is_array($newIds)) {
$oldIds = $this->lookupRelatedProductIds($object->getId());
$this->_updateLinks($object, $newIds, $oldIds, 'magefan_blog_post_relatedproduct', 'related_id');
}
return parent::_afterSave($object);
}
示例5: _afterSave
/**
* Assign page to store views
*
* @param \Magento\Framework\Model\AbstractModel $object
* @return $this
*/
protected function _afterSave(\Magento\Framework\Model\AbstractModel $object)
{
/** @var \AddictedToMagento\DynamicForms\Model\Form $object */
$oldStores = $this->lookupStoreIds($object->getId());
$newStores = (array) $object->getStores();
if (empty($newStores)) {
$newStores = (array) $object->getStoreId();
}
$table = $this->getTable(self::STORE_TABLE_NAME);
$insert = array_diff($newStores, $oldStores);
$delete = array_diff($oldStores, $newStores);
if ($delete) {
$where = ['form_id = ?' => (int) $object->getId(), 'store_id IN (?)' => $delete];
$this->getConnection()->delete($table, $where);
}
if ($insert) {
$data = [];
foreach ($insert as $storeId) {
$data[] = ['form_id' => (int) $object->getId(), 'store_id' => (int) $storeId];
}
$this->getConnection()->insertMultiple($table, $data);
}
return parent::_afterSave($object);
}
示例6: checkUrlExits
public function checkUrlExits(\Magento\Framework\Model\AbstractModel $object)
{
$stores = $object->getStores();
$connection = $this->getConnection();
$select = $connection->select()->from($this->getTable('ves_brand'), 'brand_id')->where('url_key = ?', $object->getUrlKey())->where('brand_id != ?', $object->getId());
$brandIds = $connection->fetchCol($select);
if (count($brandIds) > 0 && is_array($stores)) {
if (in_array('0', $stores)) {
throw new \Magento\Framework\Exception\LocalizedException(__('URL key for specified store already exists.'));
}
$stores[] = '0';
$select = $connection->select()->from($this->getTable('ves_brand_store'), 'brand_id')->where('brand_id IN (?)', $brandIds)->where('store_id IN (?)', $stores);
$result = $connection->fetchCol($select);
if (count($result) > 0) {
throw new \Magento\Framework\Exception\LocalizedException(__('URL key for specified store already exists.'));
}
}
return $this;
}