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