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


PHP Product::getStoreIds方法代码示例

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


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

示例1: testGetStoreIds

 public function testGetStoreIds()
 {
     $expectedStoreIds = [1, 2, 3];
     $websiteIds = ['test'];
     $this->resource->expects($this->once())->method('getWebsiteIds')->will($this->returnValue($websiteIds));
     $this->website->expects($this->once())->method('getStoreIds')->will($this->returnValue($expectedStoreIds));
     $this->assertEquals($expectedStoreIds, $this->model->getStoreIds());
 }
开发者ID:hientruong90,项目名称:magento2_installer,代码行数:8,代码来源:ProductTest.php

示例2: testGetStoreIds

 public function testGetStoreIds()
 {
     // set
     /** @var $model \Magento\Catalog\Model\Product */
     $model = $this->objectManager->create('Magento\\Catalog\\Model\\Product', ['data' => ['store_ids' => [1, 2]]]);
     $this->assertEquals([1, 2], $model->getStoreIds());
     // fixture
     $this->_model->setId($this->productRepository->get('simple')->getId());
     $this->assertEquals([1], $this->_model->getStoreIds());
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:10,代码来源:ProductExternalTest.php

示例3: testGetStoreIds

 public function testGetStoreIds()
 {
     // set
     /** @var $model \Magento\Catalog\Model\Product */
     $model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Catalog\\Model\\Product', ['data' => ['store_ids' => [1, 2]]]);
     $this->assertEquals([1, 2], $model->getStoreIds());
     // fixture
     $this->_model->setId(1);
     $this->assertEquals([1], $this->_model->getStoreIds());
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:10,代码来源:ProductExternalTest.php

示例4: extractStoreIds

 /**
  * @param \Magento\Catalog\Model\Product $product
  * @return array
  */
 protected function extractStoreIds($product)
 {
     $storeIds = $product->getStoreIds();
     $storeIds[] = \Magento\Store\Model\Store::DEFAULT_STORE_ID;
     // Removing current storeId.
     $storeIds = array_flip($storeIds);
     unset($storeIds[$product->getStoreId()]);
     $storeIds = array_keys($storeIds);
     return $storeIds;
 }
开发者ID:koliaGI,项目名称:magento2,代码行数:14,代码来源:UpdateHandler.php

示例5: generateForGlobalScope

 /**
  * Generate list of urls for global scope
  *
  * @param \Magento\Framework\Data\Collection $productCategories
  * @return \Magento\UrlRewrite\Service\V1\Data\UrlRewrite[]
  */
 protected function generateForGlobalScope($productCategories)
 {
     $urls = [];
     $productId = $this->product->getId();
     foreach ($this->product->getStoreIds() as $id) {
         if (!$this->isGlobalScope($id) && !$this->storeViewService->doesEntityHaveOverriddenUrlKeyForStore($id, $productId, Product::ENTITY)) {
             $urls = array_merge($urls, $this->generateForSpecificStoreView($id, $productCategories));
         }
     }
     return $urls;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:17,代码来源:ProductUrlRewriteGenerator.php

示例6: afterSave

 /**
  * After Save Attribute manipulation
  *
  * @param \Magento\Catalog\Model\Product $object
  * @return $this
  */
 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() == \Magento\Catalog\Model\Resource\Eav\Attribute::SCOPE_WEBSITE) {
         $baseCurrency = $this->_config->getValue(\Magento\Directory\Model\Currency::XML_PATH_CURRENCY_BASE, 'default');
         $storeIds = $object->getStoreIds();
         if (is_array($storeIds)) {
             foreach ($storeIds as $storeId) {
                 $storeCurrency = $this->_storeManager->getStore($storeId)->getBaseCurrencyCode();
                 if ($storeCurrency == $baseCurrency) {
                     continue;
                 }
                 $rate = $this->_currencyFactory->create()->load($baseCurrency)->getRate($storeCurrency);
                 if (!$rate) {
                     $rate = 1;
                 }
                 $newValue = $value * $rate;
                 $object->addAttributeUpdate($this->getAttribute()->getAttributeCode(), $newValue, $storeId);
             }
         }
     }
     return $this;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:37,代码来源:Price.php

示例7: getStoreIds

 /**
  * {@inheritdoc}
  */
 public function getStoreIds()
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'getStoreIds');
     if (!$pluginInfo) {
         return parent::getStoreIds();
     } else {
         return $this->___callPlugins('getStoreIds', func_get_args(), $pluginInfo);
     }
 }
开发者ID:dragonsword007008,项目名称:magento2,代码行数:12,代码来源:Interceptor.php


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