当前位置: 首页>>代码示例>>PHP>>正文


PHP Mage_Catalog_Model_Product::getStoreIds方法代码示例

本文整理汇总了PHP中Mage_Catalog_Model_Product::getStoreIds方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Catalog_Model_Product::getStoreIds方法的具体用法?PHP Mage_Catalog_Model_Product::getStoreIds怎么用?PHP Mage_Catalog_Model_Product::getStoreIds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mage_Catalog_Model_Product的用法示例。


在下文中一共展示了Mage_Catalog_Model_Product::getStoreIds方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: afterSave

 /**
  * After Save Attribute manipulation
  *
  * @param Mage_Catalog_Model_Product $object
  * @return Mage_Catalog_Model_Product_Attribute_Backend_Price
  */
 public function afterSave($object)
 {
     $value = $object->getData($this->getAttribute()->getAttributeCode());
     /**
      * Orig value is only for existing objects
      */
     $oridData = $object->getOrigData();
     $origValueExist = $oridData && array_key_exists($this->getAttribute()->getAttributeCode(), $oridData);
     if ($object->getStoreId() != 0 || !$value || $origValueExist) {
         return $this;
     }
     if ($this->getAttribute()->getIsGlobal() == Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE) {
         $baseCurrency = Mage::app()->getBaseCurrencyCode();
         $storeIds = $object->getStoreIds();
         if (is_array($storeIds)) {
             foreach ($storeIds as $storeId) {
                 $storeCurrency = Mage::app()->getStore($storeId)->getBaseCurrencyCode();
                 if ($storeCurrency == $baseCurrency) {
                     continue;
                 }
                 $rate = Mage::getModel('directory/currency')->load($baseCurrency)->getRate($storeCurrency);
                 if (!$rate) {
                     $rate = 1;
                 }
                 $newValue = $value * $rate;
                 $object->addAttributeUpdate($this->getAttribute()->getAttributeCode(), $newValue, $storeId);
             }
         }
     }
     return $this;
 }
开发者ID:nshiff,项目名称:magento-example,代码行数:37,代码来源:Price.php

示例2: testGetStoreIds

 public function testGetStoreIds()
 {
     // set
     /** @var $model Mage_Catalog_Model_Product */
     $model = Mage::getModel('Mage_Catalog_Model_Product', array('data' => array('store_ids' => array(1, 2))));
     $this->assertEquals(array(1, 2), $model->getStoreIds());
     // fixture
     $this->_model->setId(1);
     $this->assertEquals(array(1), $this->_model->getStoreIds());
 }
开发者ID:natxetee,项目名称:magento2,代码行数:10,代码来源:ProductExternalTest.php

示例3: getProductData

 /**
  * Create Product array from Mage_Catalog_Model_Product
  *
  * @param Mage_Catalog_Model_Product $product
  * @return array
  */
 public function getProductData(Mage_Catalog_Model_Product $product)
 {
     try {
         $data = array('url' => $product->getProductUrl(), 'title' => htmlspecialchars($product->getName()), 'spider' => 1, 'price' => $product->getPrice(), 'description' => urlencode($product->getDescription()), 'tags' => htmlspecialchars($product->getMetaKeyword()), 'images' => array(), 'vars' => array('sku' => $product->getSku(), 'storeId' => '', 'typeId' => $product->getTypeId(), 'status' => $product->getStatus(), 'categoryId' => $product->getCategoryId(), 'categoryIds' => $product->getCategoryIds(), 'websiteIds' => $product->getWebsiteIds(), 'storeIds' => $product->getStoreIds(), 'groupPrice' => $product->getGroupPrice(), 'formatedPrice' => $product->getFormatedPrice(), 'calculatedFinalPrice' => $product->getCalculatedFinalPrice(), 'minimalPrice' => $product->getMinimalPrice(), 'specialPrice' => $product->getSpecialPrice(), 'specialFromDate' => $product->getSpecialFromDate(), 'specialToDate' => $product->getSpecialToDate(), 'relatedProductIds' => $product->getRelatedProductIds(), 'upSellProductIds' => $product->getUpSellProductIds(), 'getCrossSellProductIds' => $product->getCrossSellProductIds(), 'isSuperGroup' => $product->isSuperGroup(), 'isGrouped' => $product->isGrouped(), 'isConfigurable' => $product->isConfigurable(), 'isSuper' => $product->isSuper(), 'isSalable' => $product->isSalable(), 'isAvailable' => $product->isAvailable(), 'isVirtual' => $product->isVirtual(), 'isRecurring' => $product->isRecurring(), 'isInStock' => $product->isInStock(), 'weight' => $product->getSku()));
         // Add product images
         if (self::validateProductImage($product->getImage())) {
             $data['images']['full'] = array("url" => $product->getImageUrl());
         }
         if (self::validateProductImage($product->getSmallImage())) {
             $data['images']['smallImage'] = array("url" => $product->getSmallImageUrl($width = 88, $height = 77));
         }
         if (self::validateProductImage($product->getThumbnail())) {
             $data['images']['thumb'] = array("url" => $product->getThumbnailUrl($width = 75, $height = 75));
         }
         return $data;
         return $data;
     } catch (Exception $e) {
         Mage::logException($e);
     }
 }
开发者ID:xiaoguizhidao,项目名称:sailthru-magento-extension,代码行数:26,代码来源:Content.php

示例4: _checkStoreFrom

 /**
  * Check if it possible to copy from store "store_from"
  *
  * @param Mage_Catalog_Model_Product $product
  * @param Mage_Core_Model_Website $website
  * @param array $storeData
  * @return \Mage_Catalog_Model_Api2_Product_Website_Validator_Admin_Website
  */
 protected function _checkStoreFrom($product, $website, $storeData)
 {
     if (!isset($storeData['store_from']) || !is_numeric($storeData['store_from'])) {
         $this->_addError(sprintf('Invalid value for "store_from" for the website with ID #%d.', $website->getId()));
         return $this;
     }
     // Check if the store with the specified ID (from which we will copy the information) exists
     // and if it belongs to the product being edited
     $storeFrom = Mage::getModel('core/store')->load($storeData['store_from']);
     if (!$storeFrom->getId()) {
         $this->_addError(sprintf('Store not found #%d for website #%d.', $storeData['store_from'], $website->getId()));
         return $this;
     }
     if (!in_array($storeFrom->getId(), $product->getStoreIds())) {
         $this->_addError(sprintf('Store #%d from which we will copy the information does not belong' . ' to the product #%d being edited.', $storeFrom->getId(), $product->getId()));
     }
     return $this;
 }
开发者ID:SalesOneGit,项目名称:s1_magento,代码行数:26,代码来源:Website.php

示例5: testGetStoreIds

 public function testGetStoreIds()
 {
     // set
     $model = new Mage_Catalog_Model_Product(array('store_ids' => array(1, 2)));
     $this->assertEquals(array(1, 2), $model->getStoreIds());
     // fixture
     $this->_model->setId(1);
     $this->assertEquals(array(1), $this->_model->getStoreIds());
 }
开发者ID:relue,项目名称:magento2,代码行数:9,代码来源:ProductExternalTest.php

示例6: catalogProductSaveBefore

 /**
  * Catalog product validate before saving
  *
  * @param Mage_Catalog_Model_Product $model
  */
 public function catalogProductSaveBefore($model)
 {
     // no creating products
     if (!$model->getId() && !$this->_role->getIsWebsiteLevel()) {
         $this->_throwSave();
     }
     // Disallow saving in scope of wrong store.
     // Checking store_ids bc we should check exclusive product rights on
     // all assigned stores not only on current one.
     if (($model->getId() || !$this->_role->getIsWebsiteLevel()) && !$this->_role->hasStoreAccess($model->getStoreIds())) {
         $this->_throwSave();
     }
     $websiteIds = Mage::helper('enterprise_admingws')->explodeIds($model->getWebsiteIds());
     $origWebsiteIds = $model->getResource()->getWebsiteIds($model);
     if ($this->_role->getIsWebsiteLevel()) {
         // must assign to website
         $model->setWebsiteIds($this->_forceAssignToWebsite($this->_updateSavingWebsiteIds($websiteIds, $origWebsiteIds)));
     }
     // must not assign to wrong website
     if ($model->getId() && !$this->_role->hasWebsiteAccess($model->getWebsiteIds())) {
         $this->_throwSave();
     }
 }
开发者ID:beejhuff,项目名称:magento-1.13.0.2,代码行数:28,代码来源:Models.php

示例7: _getUrlsForProduct

 /**
  * Returns all the urls related to product
  * @param Mage_Catalog_Model_Product $product
  */
 protected function _getUrlsForProduct($product)
 {
     $urls = array();
     $store_ids = $product->getStoreIds();
     foreach ($store_ids as $store_id) {
         $routePath = 'catalog/product/view';
         $routeParams['id'] = $product->getId();
         $routeParams['s'] = $product->getUrlKey();
         $routeParams['_store'] = !$store_id ? 1 : $store_id;
         $url = Mage::getUrl($routePath, $routeParams);
         $urls[] = $url;
         // Collect all rewrites
         $rewrites = Mage::getModel('core/url_rewrite')->getCollection();
         if (!Mage::getConfig('catalog/seo/product_use_categories')) {
             $rewrites->getSelect()->where("id_path = 'product/{$product->getId()}'");
         } else {
             // Also show full links with categories
             $rewrites->getSelect()->where("id_path = 'product/{$product->getId()}' OR id_path like 'product/{$product->getId()}/%'");
         }
         foreach ($rewrites as $r) {
             unset($routeParams);
             $routePath = '';
             $routeParams['_direct'] = $r->getRequestPath();
             $routeParams['_store'] = $r->getStoreId();
             $url = Mage::getUrl($routePath, $routeParams);
             $urls[] = $url;
         }
     }
     return $urls;
 }
开发者ID:nuriel77,项目名称:hypernode,代码行数:34,代码来源:Observer.php

示例8: cleanUpIndexData

 /**
  * Find and remove all solr documents which mapped to Magento product, but the magento product has no website assigned
  * @param string $solrcore
  * @param Mage_Catalog_Model_Product $_product
  */
 public function cleanUpIndexData($solrcore, $_product)
 {
     $productStoreIds = $_product->getStoreIds();
     $mappedStoreIds = $this->ultility->getMappedStoreIdsFromSolrCore($solrcore);
     if (is_array($productStoreIds) && is_array($mappedStoreIds) && $_product->getId() > 0) {
         $storeIds = array_diff($mappedStoreIds, $productStoreIds);
         if (is_array($storeIds)) {
             $queryString = '';
             foreach ($storeIds as $storeid) {
                 if ($storeid > 0) {
                     $queryString .= '<query>store_id:' . $storeid . '+AND+products_id:' . $_product->getId() . '</query>';
                 }
             }
             if (!empty($queryString)) {
                 $solrServerUrl = $this->getSolrServerUrl();
                 $deleteDocumentUrl = trim($solrServerUrl, '/') . '/' . $solrcore . '/update?stream.body=<delete>' . $queryString . '</delete>&commit=true&json.nl=map&wt=json';
                 $this->doRequest($deleteDocumentUrl);
             }
         }
     }
 }
开发者ID:shebin512,项目名称:Magento_Zoff,代码行数:26,代码来源:Solr.php

示例9: _sendOfferMessages

 protected function _sendOfferMessages(Mage_Catalog_Model_Product $product, $performThoroughCheck = false)
 {
     if ($this->_isValueRegistered('xcom_offer_messages_sent', $product->getId())) {
         return;
     }
     $this->_registerValue('xcom_offer_messages_sent', $product->getId());
     $cancelledSids = array();
     $createdSids = array();
     if ($performThoroughCheck || $product->getIsChangedWebsites()) {
         $oldWids = $this->_getRegisterValueForKey('xcom_offer_old_stores', $product->getId());
         if (!isset($oldWids)) {
             $oldWids = array();
         }
         $cancelledSids = array_diff($oldWids, $product->getStoreIds());
         $createdSids = array_diff($product->getStoreIds(), $oldWids);
     }
     $updatedSids = array_diff($product->getStoreIds(), $cancelledSids, $createdSids);
     // There is a case where product was duplicated and just now a sku was filled in
     if ($product->getOrigData()) {
         $oldSku = $product->getOrigData('sku');
         $sku = $product->getSku();
         if (empty($oldSku) && !empty($sku)) {
             $createdSids = array_merge($createdSids, $updatedSids);
             $updatedSids = array();
         }
     }
     if ($product->dataHasChangedFor('price')) {
         foreach ($updatedSids as $sid) {
             $offerInputData = array('product' => $product, 'store_id' => $sid);
             Mage::helper('xcom_xfabric')->send('com.x.webstore.v1/WebStoreOfferUpdate/WebStoreOfferPriceUpdated', $offerInputData);
         }
     }
     if ($this->_isValueRegistered('xcom_inventory_updated', $product->getId())) {
         foreach ($updatedSids as $sid) {
             $offerInputData = array('product' => $product, 'store_id' => $sid);
             Mage::helper('xcom_xfabric')->send('com.x.webstore.v1/WebStoreOfferUpdate/WebStoreOfferQuantityUpdated', $offerInputData);
         }
     }
     if ($product->dataHasChangedFor('visibility') || $product->dataHasChangedFor('status')) {
         foreach ($updatedSids as $sid) {
             $offerInputData = array('product' => $product, 'store_id' => $sid);
             Mage::helper('xcom_xfabric')->send('com.x.webstore.v1/WebStoreOfferUpdate/WebStoreOfferUpdated', $offerInputData);
         }
     }
     if ($product->dataHasChangedFor('url_key')) {
         foreach ($updatedSids as $sid) {
             Mage::getModel('xcom_chronicle/product_url_update')->setProductId($product->getEntityId())->setStoreId($sid)->setUrlPath($product->getUrlPath())->save();
         }
     }
     foreach ($createdSids as $sid) {
         $offerInputData = array('product' => $product, 'store_id' => $sid);
         Mage::helper('xcom_xfabric')->send('com.x.webstore.v1/WebStoreOfferCreation/WebStoreOfferCreated', $offerInputData);
     }
     foreach ($cancelledSids as $sid) {
         $storeProduct = $this->_getRegisterValueForKey('xcom_offer_old_stores_products', $product->getId() . '_' . $sid);
         if (empty($storeProduct)) {
             $offerInputData = array('product' => $product, 'store_id' => $sid);
         } else {
             $offerInputData = array('product' => $storeProduct);
         }
         Mage::helper('xcom_xfabric')->send('com.x.webstore.v1/WebStoreOfferDeletion/WebStoreOfferDeleted', $offerInputData);
     }
 }
开发者ID:ridhoq,项目名称:mxpi-twitter,代码行数:63,代码来源:Observer.php


注:本文中的Mage_Catalog_Model_Product::getStoreIds方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。