本文整理汇总了PHP中Mage_Core_Model_Abstract::getStores方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Core_Model_Abstract::getStores方法的具体用法?PHP Mage_Core_Model_Abstract::getStores怎么用?PHP Mage_Core_Model_Abstract::getStores使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Core_Model_Abstract
的用法示例。
在下文中一共展示了Mage_Core_Model_Abstract::getStores方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _afterSave
/**
* Perform operations after object save
*
* @param Mage_Core_Model_Abstract $object
* @return Mage_Cms_Model_Resource_Block
*/
protected function _afterSave(Mage_Core_Model_Abstract $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 = array('block_id = ?' => (int) $object->getId(), 'store_id IN (?)' => $delete);
$this->_getWriteAdapter()->delete($table, $where);
}
if ($insert) {
$data = array();
foreach ($insert as $storeId) {
$data[] = array('block_id' => (int) $object->getId(), 'store_id' => (int) $storeId);
}
$this->_getWriteAdapter()->insertMultiple($table, $data);
}
return parent::_afterSave($object);
}
示例2: _afterSave
/**
* Assign trigger to store views
*
* @param Mage_Core_Model_Abstract $object
* @return self
*/
protected function _afterSave(Mage_Core_Model_Abstract $object)
{
$oldStores = $this->lookupStoreIds($object->getId());
$newStores = (array) $object->getStores();
if (empty($newStores)) {
$newStores = (array) $object->getStoreId();
}
$table = $this->getTable('esendex_sms/trigger_store');
$insert = array_diff($newStores, $oldStores);
$delete = array_diff($oldStores, $newStores);
if (count($delete)) {
$where = ['trigger_id = ?' => (int) $object->getId(), 'store_id IN (?)' => $delete];
$this->_getWriteAdapter()->delete($table, $where);
}
if (count($insert)) {
$data = [];
foreach ($insert as $storeId) {
$data[] = ['trigger_id' => (int) $object->getId(), 'store_id' => (int) $storeId];
}
$this->_getWriteAdapter()->insertMultiple($table, $data);
}
return parent::_afterSave($object);
}
示例3: _afterSave
/**
* Perform actions after object save
*
* @param Varien_Object $object
* @return Mage_Review_Model_Resource_Review
*/
protected function _afterSave(Mage_Core_Model_Abstract $object)
{
$adapter = $this->_getWriteAdapter();
/**
* save detail
*/
$detail = array('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, array(':review_id' => $object->getId()));
if ($detailId) {
$condition = array("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 = array('review_id = ?' => $object->getId());
$adapter->delete($this->_reviewStoreTable, $condition);
$insertedStoreIds = array();
foreach ($stores as $storeId) {
if (in_array($storeId, $insertedStoreIds)) {
continue;
}
$insertedStoreIds[] = $storeId;
$storeInsert = array('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: _afterSave
/**
* Assign page to store views
*
* @param Mage_Core_Model_Abstract $object
* @return Mage_Cms_Model_Resource_Page
*/
protected function _afterSave(Mage_Core_Model_Abstract $object)
{
$oldStores = $this->lookupStoreIds($object->getId());
$newStores = (array) $object->getStores();
if (empty($newStores)) {
$newStores = (array) $object->getStoreId();
}
$table = $this->getTable('cms/page_store');
$insert = array_diff($newStores, $oldStores);
$delete = array_diff($oldStores, $newStores);
if ($delete) {
$where = array('page_id = ?' => (int) $object->getId(), 'store_id IN (?)' => $delete);
$this->_getWriteAdapter()->delete($table, $where);
}
if ($insert) {
$data = array();
foreach ($insert as $storeId) {
$data[] = array('page_id' => (int) $object->getId(), 'store_id' => (int) $storeId);
}
$this->_getWriteAdapter()->insertMultiple($table, $data);
}
//Mark layout cache as invalidated
Mage::app()->getCacheInstance()->invalidateType('layout');
return parent::_afterSave($object);
}
示例5: _addLinkStores
/**
* Add link stores for custom method
*
* @param Mage_Core_Model_Abstract $object
*
* @return MatheusGontijo_EasyShippingRules_Model_Resource_Custommethod
*/
protected function _addLinkStores(Mage_Core_Model_Abstract $object)
{
$oldStores = $this->lookupStoreIds($object->getId());
$newStores = (array) $object->getStores();
if (empty($newStores)) {
$newStores = (array) $object->getStoreId();
}
$table = $this->getTable('easyshippingrules/custom_method_store');
$insert = array_diff($newStores, $oldStores);
$delete = array_diff($oldStores, $newStores);
if ($delete) {
$where = array('easyshippingrules_custom_method_id = ?' => $object->getId(), 'store_id IN (?)' => $delete);
$this->_getWriteAdapter()->delete($table, $where);
}
if ($insert) {
$data = array();
foreach ($insert as $storeId) {
$data[] = array('easyshippingrules_custom_method_id' => $object->getId(), 'store_id' => $storeId);
}
$this->_getWriteAdapter()->insertMultiple($table, $data);
}
return $this;
}
示例6: _afterSave
/**
* Function called after a model is saved
* Save store associations
*
* @param Mage_Core_Model_Abstract $object
* @return $this
*/
protected function _afterSave(Mage_Core_Model_Abstract $object)
{
if ($object->getId()) {
$oldStores = $this->lookupStoreIds($object->getId());
$newStores = (array) $object->getStores();
if (empty($newStores)) {
$newStores = (array) $object->getStoreId();
}
$table = $this->getTable('splash/page_store');
$insert = array_diff($newStores, $oldStores);
$delete = array_diff($oldStores, $newStores);
if ($delete) {
$this->_getWriteAdapter()->delete($table, array('page_id = ?' => (int) $object->getId(), 'store_id IN (?)' => $delete));
}
if ($insert) {
$data = array();
foreach ($insert as $storeId) {
$data[] = array('page_id' => (int) $object->getId(), 'store_id' => (int) $storeId);
}
$this->_getWriteAdapter()->insertMultiple($table, $data);
}
}
// Ensure that attribute's used are set to be used in the product listing
if (is_array($optionFilters = $object->getOptionFilters())) {
foreach ($optionFilters as $attribute => $data) {
$attribute = Mage::getSingleton('eav/config')->getAttribute('catalog_product', $attribute);
if ($attribute->getId() && !$attribute->getUsedInProductListing()) {
try {
$attribute->setUsedInProductListing(1)->save();
} catch (Exception $e) {
Mage::logException($e);
}
}
}
}
return parent::_afterSave($object);
}
示例7: _afterSave
/**
* Assign image to store views
*
* @param Mage_Core_Model_Abstract $object
* @return Devils_HomeWidget_Model_Resource_Image
*/
protected function _afterSave(Mage_Core_Model_Abstract $object)
{
$entityId = (int) $object->getId();
$oldStores = $this->lookupStoreIds($entityId);
$newStores = (array) $object->getStores();
if (empty($newStores)) {
$newStores = (array) $object->getStoreId();
}
$table = $this->getTable('devils_homewidget/image_store');
$insertStores = array_diff($newStores, $oldStores);
$deleteStores = array_diff($oldStores, $newStores);
if ($deleteStores) {
$where = array('entity_id = ?' => $entityId, 'store_id IN (?)' => $deleteStores);
$this->_getWriteAdapter()->delete($table, $where);
}
if ($insertStores) {
$data = array();
foreach ($insertStores as $storeId) {
$data[] = array('entity_id' => $entityId, 'store_id' => (int) $storeId);
}
$this->_getWriteAdapter()->insertMultiple($table, $data);
}
$areas = $object->getAreas();
$table = $this->getTable('devils_homewidget/image_area');
$where = array('entity_id = ?' => $entityId);
$this->_getWriteAdapter()->delete($table, $where);
foreach ($areas as &$area) {
$area['entity_id'] = $entityId;
}
$this->_getWriteAdapter()->insertMultiple($table, $areas);
//Mark layout cache as invalidated
Mage::app()->getCacheInstance()->invalidateType('layout');
return parent::_afterSave($object);
}