本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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());
}
示例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;
}
示例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;
}
示例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());
}
示例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);
}
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}