本文整理汇总了PHP中Magento\Framework\Model\AbstractModel::dataHasChangedFor方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractModel::dataHasChangedFor方法的具体用法?PHP AbstractModel::dataHasChangedFor怎么用?PHP AbstractModel::dataHasChangedFor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Model\AbstractModel
的用法示例。
在下文中一共展示了AbstractModel::dataHasChangedFor方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: aroundSave
/**
* Invalidate indexer on attribute save (searchable flag change)
*
* @param \Magento\Catalog\Model\Resource\Attribute $subject
* @param \Closure $proceed
* @param \Magento\Framework\Model\AbstractModel $attribute
*
* @return \Magento\Catalog\Model\Resource\Attribute
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function aroundSave(\Magento\Catalog\Model\Resource\Attribute $subject, \Closure $proceed, \Magento\Framework\Model\AbstractModel $attribute)
{
$needInvalidation = ($attribute->dataHasChangedFor('is_searchable') || $attribute->dataHasChangedFor('is_filterable') || $attribute->dataHasChangedFor('is_visible_in_advanced_search')) && !$attribute->isObjectNew();
$result = $proceed($attribute);
if ($needInvalidation) {
$this->indexerRegistry->get(Fulltext::INDEXER_ID)->invalidate();
}
return $result;
}
示例2: aroundSave
/**
* @param \Magento\Store\Model\ResourceModel\Group $object
* @param callable $proceed
* @param AbstractModel $group
* @return \Magento\Store\Model\ResourceModel\Group
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function aroundSave(\Magento\Store\Model\ResourceModel\Group $object, \Closure $proceed, AbstractModel $group)
{
$originGroup = $group;
$result = $proceed($originGroup);
if (!$group->isObjectNew() && ($group->dataHasChangedFor('website_id') || $group->dataHasChangedFor('root_category_id'))) {
$this->storeManager->reinitStores();
foreach ($group->getStoreIds() as $storeId) {
$this->urlPersist->deleteByData([UrlRewrite::STORE_ID => $storeId]);
}
$this->urlPersist->replace($this->generateCategoryUrls($group->getRootCategoryId(), $group->getStoreIds()));
$this->urlPersist->replace($this->generateProductUrls($group->getWebsiteId(), $group->getOrigData('website_id')));
}
return $result;
}
示例3: aroundSave
/**
* Invalidate indexer on store group save
*
* @param \Magento\Store\Model\Resource\Group $subject
* @param \Closure $proceed
* @param \Magento\Framework\Model\AbstractModel $group
*
* @return \Magento\Store\Model\Resource\Group
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function aroundSave(\Magento\Store\Model\Resource\Group $subject, \Closure $proceed, \Magento\Framework\Model\AbstractModel $group)
{
$needInvalidation = !$group->isObjectNew() && $group->dataHasChangedFor('website_id');
$result = $proceed($group);
if ($needInvalidation) {
$this->indexerRegistry->get(Fulltext::INDEXER_ID)->invalidate();
}
return $result;
}
示例4: aroundSave
/**
* Invalidate indexer on attribute save (searchable flag change)
*
* @param \Magento\Catalog\Model\Resource\Attribute $subject
* @param \Closure $proceed
* @param \Magento\Framework\Model\AbstractModel $attribute
*
* @return \Magento\Catalog\Model\Resource\Attribute
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function aroundSave(\Magento\Catalog\Model\Resource\Attribute $subject, \Closure $proceed, \Magento\Framework\Model\AbstractModel $attribute)
{
$needInvalidation = !$attribute->isObjectNew() && $attribute->dataHasChangedFor('is_searchable');
$result = $proceed($attribute);
if ($needInvalidation) {
$this->getIndexer()->invalidate();
}
return $result;
}
示例5: getUrlPath
/**
* Build category URL path
*
* @param \Magento\Catalog\Api\Data\CategoryInterface|\Magento\Framework\Model\AbstractModel $category
* @return string
*/
public function getUrlPath($category)
{
if ($category->getParentId() == Category::TREE_ROOT_ID) {
return '';
}
$path = $category->getUrlPath();
if ($path !== null && !$category->dataHasChangedFor('url_key') && !$category->dataHasChangedFor('parent_id')) {
return $path;
}
$path = $category->getUrlKey();
if ($path === false) {
return $category->getUrlPath();
}
if ($this->isNeedToGenerateUrlPathForParent($category)) {
$parentPath = $this->getUrlPath($this->categoryRepository->get($category->getParentId()));
$path = $parentPath === '' ? $path : $parentPath . '/' . $path;
}
return $path;
}
示例6: testOrigData
/**
* Tests \Magento\Framework\Object->setOrigData()
*/
public function testOrigData()
{
$data = ['key1' => 'value1', 'key2' => 'value2'];
$this->model->setData($data);
$this->model->setOrigData();
$this->model->setData('key1', 'test');
$this->assertTrue($this->model->dataHasChangedFor('key1'));
$this->assertEquals($data, $this->model->getOrigData());
$this->model->setOrigData('key1', 'test');
$this->assertEquals('test', $this->model->getOrigData('key1'));
}
示例7: _beforeSave
/**
* {@inheritdoc}
*/
protected function _beforeSave(AbstractModel $object)
{
$reindexRequired = false;
if ($object->hasData('attributes') && is_array($object->getData('attributes'))) {
$serialized = serialize($object->getData('attributes'));
if ($object->getData('attributes_serialized') != $serialized) {
$reindexRequired = true;
}
$object->setData('attributes_serialized', $serialized);
}
if ($object->hasData('properties') && is_array($object->getData('properties'))) {
$serialized = serialize($object->getData('properties'));
if ($object->getData('properties_serialized') != $serialized) {
$reindexRequired = true;
}
$object->setData('properties_serialized', $serialized);
}
if ($reindexRequired && !$object->dataHasChangedFor('status')) {
$object->setStatus(Config::INDEX_STATUS_INVALID);
}
$object->setCode($object->getCode());
return $this;
}
示例8: beforeSave
/**
* Before save handler
*
* @param \Magento\Store\Model\ResourceModel\Group $subject
* @param \Magento\Framework\Model\AbstractModel $object
*
* @return void
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function beforeSave(\Magento\Store\Model\ResourceModel\Group $subject, \Magento\Framework\Model\AbstractModel $object)
{
if (!$object->getId() || $object->dataHasChangedFor('root_category_id')) {
$this->_productFlatIndexerProcessor->markIndexerAsInvalid();
}
}
示例9: validate
/**
* Validate changes for invalidating indexer
*
* @param \Magento\Framework\Model\AbstractModel $group
* @return bool
*/
protected function validate(\Magento\Framework\Model\AbstractModel $group)
{
return ($group->dataHasChangedFor('website_id') || $group->dataHasChangedFor('root_category_id')) && !$group->isObjectNew();
}
示例10: beforeSave
/**
* Before save handler
*
* @param \Magento\Store\Model\Resource\Group $subject
* @param \Magento\Framework\Model\AbstractModel $object
*
* @return void
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function beforeSave(\Magento\Store\Model\Resource\Group $subject, \Magento\Framework\Model\AbstractModel $object)
{
if (!$object->getId() || $object->dataHasChangedFor('website_id')) {
$this->_indexerProcessor->markIndexerAsInvalid();
}
}
示例11: validate
/**
* Validate changes for invalidating indexer
*
* @param \Magento\Framework\Model\AbstractModel $store
* @return bool
*/
protected function validate(\Magento\Framework\Model\AbstractModel $store)
{
return $store->isObjectNew() || $store->dataHasChangedFor('group_id');
}
示例12: _afterSave
/**
* Save attribute/form relations after attribute save
*
* @param \Magento\Framework\Model\AbstractModel $object
* @return $this
*/
protected function _afterSave(AbstractModel $object)
{
$forms = $object->getData('used_in_forms');
$adapter = $this->_getWriteAdapter();
if (is_array($forms)) {
$where = array('attribute_id=?' => $object->getId());
$adapter->delete($this->_getFormAttributeTable(), $where);
$data = array();
foreach ($forms as $formCode) {
$data[] = array('form_code' => $formCode, 'attribute_id' => (int) $object->getId());
}
if ($data) {
$adapter->insertMultiple($this->_getFormAttributeTable(), $data);
}
}
// update sort order
if (!$object->isObjectNew() && $object->dataHasChangedFor('sort_order')) {
$data = array('sort_order' => $object->getSortOrder());
$where = array('attribute_id=?' => (int) $object->getId());
$adapter->update($this->getTable('eav_entity_attribute'), $data, $where);
}
// save scope attributes
$websiteId = (int) $object->getWebsite()->getId();
if ($websiteId) {
$table = $this->_getEavWebsiteTable();
$describe = $this->_getReadAdapter()->describeTable($table);
$data = array();
if (!$object->getScopeWebsiteId() || $object->getScopeWebsiteId() != $websiteId) {
$data = $this->getScopeValues($object);
}
$data['attribute_id'] = (int) $object->getId();
$data['website_id'] = (int) $websiteId;
unset($describe['attribute_id']);
unset($describe['website_id']);
$updateColumns = array();
foreach (array_keys($describe) as $columnName) {
$data[$columnName] = $object->getData('scope_' . $columnName);
$updateColumns[] = $columnName;
}
$adapter->insertOnDuplicate($table, $data, $updateColumns);
}
return parent::_afterSave($object);
}
示例13: beforeSave
/**
* Before save handler
*
* @param \Magento\Store\Model\ResourceModel\Store $subject
* @param \Magento\Framework\Model\AbstractModel $object
*
* @return void
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function beforeSave(\Magento\Store\Model\ResourceModel\Store $subject, \Magento\Framework\Model\AbstractModel $object)
{
if ((!$object->getId() || $object->dataHasChangedFor('group_id')) && $object->getIsActive()) {
$this->_indexerEavProcessor->markIndexerAsInvalid();
}
}
示例14: aroundSave
/**
* @param \Magento\Store\Model\ResourceModel\Store $object
* @param callable $proceed
* @param AbstractModel $store
* @return \Magento\Store\Model\ResourceModel\Store
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function aroundSave(\Magento\Store\Model\ResourceModel\Store $object, \Closure $proceed, AbstractModel $store)
{
$originStore = $store;
$result = $proceed($originStore);
if ($store->isObjectNew() || $store->dataHasChangedFor('group_id')) {
if (!$store->isObjectNew()) {
$this->urlPersist->deleteByData([UrlRewrite::STORE_ID => $store->getId()]);
}
$this->urlPersist->replace($this->generateCategoryUrls($store->getRootCategoryId(), $store->getId()));
$this->urlPersist->replace($this->generateProductUrls($store->getWebsiteId(), $store->getOrigData('website_id'), $store->getId()));
}
return $result;
}