當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Product::getStoreId方法代碼示例

本文整理匯總了PHP中Magento\Catalog\Model\Product::getStoreId方法的典型用法代碼示例。如果您正苦於以下問題:PHP Product::getStoreId方法的具體用法?PHP Product::getStoreId怎麽用?PHP Product::getStoreId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Catalog\Model\Product的用法示例。


在下文中一共展示了Product::getStoreId方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: generate

 /**
  * Generate product url rewrites
  *
  * @param \Magento\Catalog\Model\Product $product
  * @return \Magento\UrlRewrite\Service\V1\Data\UrlRewrite[]
  */
 public function generate(Product $product)
 {
     $this->product = $product;
     $storeId = $this->product->getStoreId();
     $productCategories = $product->getCategoryCollection()->addAttributeToSelect('url_key')->addAttributeToSelect('url_path');
     $urls = $this->isGlobalScope($storeId) ? $this->generateForGlobalScope($productCategories) : $this->generateForSpecificStoreView($storeId, $productCategories);
     $this->product = null;
     return $urls;
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:15,代碼來源:ProductUrlRewriteGenerator.php

示例2: loadProductGalleryByAttributeId

 /**
  * @param Product $product
  * @param int $attributeId
  * @return array
  */
 public function loadProductGalleryByAttributeId($product, $attributeId)
 {
     $select = $this->createBaseLoadSelect($product->getId(), $product->getStoreId(), $attributeId);
     $result = $this->getConnection()->fetchAll($select);
     $this->_removeDuplicates($result);
     return $result;
 }
開發者ID:whoople,項目名稱:magento2-testing,代碼行數:12,代碼來源:Media.php

示例3: setProduct

 /**
  * @param \Magento\Catalog\Model\Product $productModel
  * @return \Ess\M2ePro\Model\Magento\Product
  */
 public function setProduct(\Magento\Catalog\Model\Product $productModel)
 {
     $this->_productModel = $productModel;
     $this->setProductId($this->_productModel->getId());
     $this->setStoreId($this->_productModel->getStoreId());
     return $this;
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:11,代碼來源:Product.php

示例4: convertAttribute

 /**
  * Set current attribute to entry (for specified product)
  *
  * @param \Magento\Catalog\Model\Product $product
  * @param \Magento\Framework\Gdata\Gshopping\Entry $entry
  * @return \Magento\Framework\Gdata\Gshopping\Entry
  */
 public function convertAttribute($product, $entry)
 {
     $targetCountry = $this->_config->getTargetCountry($product->getStoreId());
     $value = $this->_typeFactory->create()->loadByAttributeSetId($product->getAttributeSetId(), $targetCountry);
     $val = $value->getCategory() == \Magento\GoogleShopping\Helper\Category::CATEGORY_OTHER ? '' : $value->getCategory();
     $this->_setAttribute($entry, 'google_product_category', self::ATTRIBUTE_TYPE_TEXT, htmlspecialchars_decode($val, ENT_NOQUOTES));
     return $entry;
 }
開發者ID:Atlis,項目名稱:docker-magento2,代碼行數:15,代碼來源:GoogleProductCategory.php

示例5: testGetStoreId

 public function testGetStoreId()
 {
     $this->model->setStoreId(3);
     $this->assertEquals(3, $this->model->getStoreId());
     $this->model->unsStoreId();
     $this->store->expects($this->once())->method('getId')->will($this->returnValue(5));
     $this->assertEquals(5, $this->model->getStoreId());
 }
開發者ID:hientruong90,項目名稱:magento2_installer,代碼行數:8,代碼來源:ProductTest.php

示例6: generate

 /**
  * {@inheritdoc}
  */
 public function generate($product)
 {
     $this->product = $product;
     $storeId = $this->product->getStoreId();
     $urls = $this->catalogUrlRewriteHelper->isDefaultStore($storeId) ? $this->generateForDefaultStore() : $this->generateForStore($storeId);
     $this->product = null;
     $this->categories = null;
     return $urls;
 }
開發者ID:aiesh,項目名稱:magento2,代碼行數:12,代碼來源:ProductUrlGenerator.php

示例7: createSampleModel

 /**
  * @param \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject $product
  * @param array $modelData
  * @return \Magento\Downloadable\Model\Sample|\PHPUnit_Framework_MockObject_MockObject
  */
 private function createSampleModel($product, array $modelData)
 {
     $sample = $this->getMockBuilder('\\Magento\\Downloadable\\Model\\Sample')->disableOriginalConstructor()->setMethods(['setData', 'setSampleType', 'setProductId', 'setStoreId', 'setProductWebsiteIds', 'setNumberOfDownloads', 'setSampleUrl', 'setLinkFile', 'setSampleFile', 'save'])->getMock();
     $sample->expects($this->once())->method('setData')->with($modelData)->will($this->returnSelf());
     $sample->expects($this->once())->method('setSampleType')->with($modelData['type'])->will($this->returnSelf());
     $sample->expects($this->once())->method('setProductId')->with($product->getId())->will($this->returnSelf());
     $sample->expects($this->once())->method('setStoreId')->with($product->getStoreId())->will($this->returnSelf());
     return $sample;
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:14,代碼來源:SampleTest.php

示例8: testConvertAttribute

 /**
  * @param \Magento\Catalog\Model\Product $product
  * @param \Magento\Framework\Gdata\Gshopping\Entry $entry
  * @dataProvider convertAttributeDataProvider
  */
 public function testConvertAttribute($product, $entry)
 {
     /** @var \Magento\GoogleShopping\Model\Attribute\Price $model */
     $model = Bootstrap::getObjectManager()->create('Magento\\GoogleShopping\\Model\\Attribute\\Price');
     $groupManagement = Bootstrap::getObjectManager()->get('Magento\\Customer\\Api\\GroupManagementInterface');
     $defaultCustomerGroup = $groupManagement->getDefaultGroup($product->getStoreId());
     $model->convertAttribute($product, $entry);
     $this->assertEquals($defaultCustomerGroup->getId(), $product->getCustomerGroupId());
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:14,代碼來源:PriceTest.php

示例9: getStoreId

 /**
  * {@inheritdoc}
  */
 public function getStoreId()
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'getStoreId');
     if (!$pluginInfo) {
         return parent::getStoreId();
     } else {
         return $this->___callPlugins('getStoreId', func_get_args(), $pluginInfo);
     }
 }
開發者ID:dragonsword007008,項目名稱:magento2,代碼行數:12,代碼來源:Interceptor.php

示例10: getUrl

 /**
  * The only rewritten line in this method is the return statement
  */
 public function getUrl(\Magento\Catalog\Model\Product $product, $params = [])
 {
     $routePath = '';
     $routeParams = $params;
     $storeId = $product->getStoreId();
     $categoryId = null;
     if (!isset($params['_ignore_category']) && $product->getCategoryId() && !$product->getDoNotUseCategoryId()) {
         $categoryId = $product->getCategoryId();
     }
     if ($product->hasUrlDataObject()) {
         $requestPath = $product->getUrlDataObject()->getUrlRewrite();
         $routeParams['_scope'] = $product->getUrlDataObject()->getStoreId();
     } else {
         $requestPath = $product->getRequestPath();
         if (empty($requestPath) && $requestPath !== false) {
             $filterData = [UrlRewrite::ENTITY_ID => $product->getId(), UrlRewrite::ENTITY_TYPE => \Magento\CatalogUrlRewrite\Model\ProductUrlRewriteGenerator::ENTITY_TYPE, UrlRewrite::STORE_ID => $storeId];
             if ($categoryId) {
                 $filterData[UrlRewrite::METADATA]['category_id'] = $categoryId;
             }
             $rewrite = $this->urlFinder->findOneByData($filterData);
             if ($rewrite) {
                 $requestPath = $rewrite->getRequestPath();
                 $product->setRequestPath($requestPath);
             } else {
                 $product->setRequestPath(false);
             }
         }
     }
     if (isset($routeParams['_scope'])) {
         $storeId = $this->storeManager->getStore($routeParams['_scope'])->getId();
     }
     if ($storeId != $this->storeManager->getStore()->getId()) {
         $routeParams['_scope_to_url'] = true;
     }
     if (!empty($requestPath)) {
         $routeParams['_direct'] = $requestPath;
     } else {
         $routePath = 'catalog/product/view';
         $routeParams['id'] = $product->getId();
         $routeParams['s'] = $product->getUrlKey();
         if ($categoryId) {
             $routeParams['category'] = $categoryId;
         }
     }
     // reset cached URL instance GET query params
     if (!isset($routeParams['_query'])) {
         $routeParams['_query'] = [];
     }
     /*
      * This is the only line changed from the default method.
      * For reference, the original line: $this->getUrlInstance()->setScope($storeId)->getUrl($routePath, $routeParams);
      * getUrlInstance() is a private method, so a new method has been written that will create a frontend Url object if
      * the store scope is not the admin scope.
      */
     return $this->getStoreScopeUrlInstance($storeId)->getUrl($routePath, $routeParams);
 }
開發者ID:algolia,項目名稱:algoliasearch-magento-2,代碼行數:59,代碼來源:Url.php

示例11: 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

示例12: loadGallery

 /**
  * Load gallery images for product
  *
  * @param \Magento\Catalog\Model\Product $product
  * @param \Magento\Catalog\Model\Product\Attribute\Backend\Media $object
  * @return array
  */
 public function loadGallery($product, $object)
 {
     $adapter = $this->_getReadAdapter();
     $positionCheckSql = $adapter->getCheckSql('value.position IS NULL', 'default_value.position', 'value.position');
     // Select gallery images for product
     $select = $adapter->select()->from(array('main' => $this->getMainTable()), array('value_id', 'value AS file'))->joinLeft(array('value' => $this->getTable(self::GALLERY_VALUE_TABLE)), $adapter->quoteInto('main.value_id = value.value_id AND value.store_id = ?', (int) $product->getStoreId()), array('label', 'position', 'disabled'))->joinLeft(array('default_value' => $this->getTable(self::GALLERY_VALUE_TABLE)), 'main.value_id = default_value.value_id AND default_value.store_id = 0', array('label_default' => 'label', 'position_default' => 'position', 'disabled_default' => 'disabled'))->where('main.attribute_id = ?', $object->getAttribute()->getId())->where('main.entity_id = ?', $product->getId())->order($positionCheckSql . ' ' . \Magento\Framework\DB\Select::SQL_ASC);
     $result = $adapter->fetchAll($select);
     $this->_removeDuplicates($result);
     return $result;
 }
開發者ID:aiesh,項目名稱:magento2,代碼行數:17,代碼來源:Media.php

示例13: testExecuteUrlKey

 /**
  * @param bool $isChangedUrlKey
  * @param bool $isChangedVisibility
  * @param bool $isChangedWebsites
  * @param bool $isChangedCategories
  * @param bool $visibilityResult
  * @param int $expectedDeleteCount
  * @param int $expectedReplaceCount
  *
  * @dataProvider testUrlKeyDataProvider
  */
 public function testExecuteUrlKey($isChangedUrlKey, $isChangedVisibility, $isChangedWebsites, $isChangedCategories, $visibilityResult, $expectedDeleteCount, $expectedReplaceCount)
 {
     $this->product->expects($this->any())->method('getStoreId')->will($this->returnValue(12));
     $this->product->expects($this->any())->method('dataHasChangedFor')->will($this->returnValueMap([['visibility', $isChangedVisibility], ['url_key', $isChangedUrlKey]]));
     $this->product->expects($this->any())->method('getIsChangedWebsites')->will($this->returnValue($isChangedWebsites));
     $this->product->expects($this->any())->method('getIsChangedCategories')->will($this->returnValue($isChangedCategories));
     $this->urlPersist->expects($this->exactly($expectedDeleteCount))->method('deleteByData')->with([UrlRewrite::ENTITY_ID => $this->product->getId(), UrlRewrite::ENTITY_TYPE => ProductUrlRewriteGenerator::ENTITY_TYPE, UrlRewrite::REDIRECT_TYPE => 0, UrlRewrite::STORE_ID => $this->product->getStoreId()]);
     $this->product->expects($this->any())->method('isVisibleInSiteVisibility')->will($this->returnValue($visibilityResult));
     $this->urlPersist->expects($this->exactly($expectedReplaceCount))->method('replace')->with([3 => 'rewrite']);
     $this->model->execute($this->observer);
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:22,代碼來源:ProductProcessUrlRewriteSavingObserverTest.php

示例14: generate

 /**
  * Generate product url rewrites
  *
  * @param \Magento\Catalog\Model\Product $product
  * @return \Magento\UrlRewrite\Service\V1\Data\UrlRewrite[]
  */
 public function generate(Product $product)
 {
     if ($product->getVisibility() == Visibility::VISIBILITY_NOT_VISIBLE) {
         return [];
     }
     $this->product = $product;
     $storeId = $this->product->getStoreId();
     $productCategories = $product->getCategoryCollection()->addAttributeToSelect('url_key')->addAttributeToSelect('url_path');
     $urls = $this->isGlobalScope($storeId) ? $this->generateForGlobalScope($productCategories) : $this->generateForSpecificStoreView($storeId, $productCategories);
     $this->product = null;
     return $urls;
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:18,代碼來源:ProductUrlRewriteGenerator.php

示例15: deleteProductData

 /**
  * Delete product data
  *
  * @param \Magento\Catalog\Model\Product $product
  * @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute
  * @return $this
  */
 public function deleteProductData($product, $attribute)
 {
     $where = ['entity_id = ?' => (int) $product->getId(), 'attribute_id = ?' => (int) $attribute->getId()];
     $connection = $this->getConnection();
     if (!$attribute->isScopeGlobal()) {
         $storeId = $product->getStoreId();
         if ($storeId) {
             $where['website_id IN(?)'] = [0, $this->_storeManager->getStore($storeId)->getWebsiteId()];
         }
     }
     $connection->delete($this->getMainTable(), $where);
     return $this;
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:20,代碼來源:Tax.php


注:本文中的Magento\Catalog\Model\Product::getStoreId方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。