Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/MAGETWO-37820-preference-in-the-…
Browse files Browse the repository at this point in the history
…wrong-di-xml' into develop
  • Loading branch information
Joan He committed Oct 29, 2015
2 parents 9542e30 + a33e4d3 commit c9b1de3
Show file tree
Hide file tree
Showing 22 changed files with 119 additions and 106 deletions.
10 changes: 5 additions & 5 deletions app/code/Magento/Bundle/Setup/InstallData.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface
'input' => '',
'class' => '',
'source' => '',
'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_GLOBAL,
'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL,
'visible' => true,
'required' => true,
'user_defined' => false,
Expand All @@ -112,7 +112,7 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface
'input' => '',
'class' => '',
'source' => '',
'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_GLOBAL,
'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL,
'visible' => false,
'required' => true,
'user_defined' => false,
Expand All @@ -137,7 +137,7 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface
'input' => '',
'class' => '',
'source' => '',
'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_GLOBAL,
'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL,
'visible' => false,
'required' => true,
'user_defined' => false,
Expand All @@ -164,7 +164,7 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface
'input' => 'select',
'class' => '',
'source' => 'Magento\Bundle\Model\Product\Attribute\Source\Price\View',
'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_GLOBAL,
'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL,
'visible' => true,
'required' => true,
'user_defined' => false,
Expand All @@ -190,7 +190,7 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface
'input' => '',
'class' => '',
'source' => '',
'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_GLOBAL,
'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL,
'visible' => false,
'required' => true,
'user_defined' => false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,14 @@ protected function _prepareForm()
}

$scopes = [
\Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE => __('Store View'),
\Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_WEBSITE => __('Website'),
\Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_GLOBAL => __('Global'),
\Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE => __('Store View'),
\Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_WEBSITE => __('Website'),
\Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL => __('Global'),
];

if ($attributeObject->getAttributeCode() == 'status' || $attributeObject->getAttributeCode() == 'tax_class_id'
) {
unset($scopes[\Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE]);
unset($scopes[\Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE]);
}

$fieldset->addField(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ protected function _prepareColumns()
'index' => 'is_global',
'type' => 'options',
'options' => [
\Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE => __('Store View'),
\Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_WEBSITE => __('Web Site'),
\Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_GLOBAL => __('Global'),
\Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE => __('Store View'),
\Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_WEBSITE => __('Web Site'),
\Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL => __('Global'),
],
'align' => 'center'
],
Expand Down
8 changes: 4 additions & 4 deletions app/code/Magento/Catalog/Model/Attribute/Source/Scopes.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
namespace Magento\Catalog\Model\Attribute\Source;

use \Magento\Catalog\Model\ResourceModel\Eav\Attribute;
use \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface;

class Scopes implements \Magento\Framework\Data\OptionSourceInterface
{
Expand All @@ -16,15 +16,15 @@ public function toOptionArray()
{
return [
[
'value' => Attribute::SCOPE_STORE,
'value' => ScopedAttributeInterface::SCOPE_STORE,
'label' => __('Store View'),
],
[
'value' => Attribute::SCOPE_WEBSITE,
'value' => ScopedAttributeInterface::SCOPE_WEBSITE,
'label' => __('Web Site'),
],
[
'value' => Attribute::SCOPE_GLOBAL,
'value' => ScopedAttributeInterface::SCOPE_GLOBAL,
'label' => __('Global'),
],
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
*/
namespace Magento\Catalog\Model\Product\Attribute\Backend;

use \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface;

/**
* Catalog product price attribute backend model
*
Expand Down Expand Up @@ -91,9 +93,9 @@ public function setAttribute($attribute)
public function setScope($attribute)
{
if ($this->_helper->isPriceGlobal()) {
$attribute->setIsGlobal(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_GLOBAL);
$attribute->setIsGlobal(ScopedAttributeInterface::SCOPE_GLOBAL);
} else {
$attribute->setIsGlobal(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_WEBSITE);
$attribute->setIsGlobal(ScopedAttributeInterface::SCOPE_WEBSITE);
}

return $this;
Expand All @@ -118,7 +120,7 @@ public function afterSave($object)
return $this;
}

if ($this->getAttribute()->getIsGlobal() == \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_WEBSITE) {
if ($this->getAttribute()->getIsGlobal() == ScopedAttributeInterface::SCOPE_WEBSITE) {
$baseCurrency = $this->_config->getValue(
\Magento\Directory\Model\Currency::XML_PATH_CURRENCY_BASE,
'default'
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Catalog/Model/ResourceModel/Attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ protected function _clearUselessAttributeValues(\Magento\Framework\Model\Abstrac

if ($object->isScopeGlobal() && isset(
$origData['is_global']
) && \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_GLOBAL != $origData['is_global']
) && \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL != $origData['is_global']
) {
$attributeStoreIds = array_keys($this->_storeManager->getStores());
if (!empty($attributeStoreIds)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,8 @@
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
*/
class Attribute extends \Magento\Eav\Model\Entity\Attribute implements
\Magento\Catalog\Api\Data\ProductAttributeInterface
\Magento\Catalog\Api\Data\ProductAttributeInterface, \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface
{
const SCOPE_STORE = 0;

const SCOPE_GLOBAL = 1;

const SCOPE_WEBSITE = 2;

const MODULE_NAME = 'Magento_Catalog';

const ENTITY = 'catalog_eav_attribute';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function map(array $input, $entityTypeId)
'is_global' => $this->_getValue(
$input,
'global',
\Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_GLOBAL
\Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL
),
'is_visible' => $this->_getValue($input, 'visible', 1),
'is_searchable' => $this->_getValue($input, 'searchable', 0),
Expand Down
Loading

0 comments on commit c9b1de3

Please sign in to comment.