Skip to content

Commit

Permalink
#11888: Merge branch '2.3-develop' of github.com:magento/magento2 int…
Browse files Browse the repository at this point in the history
…o FR#BackgroundImage23
  • Loading branch information
ishakhsuvarov committed Nov 3, 2017
2 parents 9c80e90 + 14b165e commit befe833
Show file tree
Hide file tree
Showing 93 changed files with 4,491 additions and 265 deletions.
106 changes: 60 additions & 46 deletions app/code/Magento/Catalog/Model/ResourceModel/Product/Option/Value.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,53 +5,66 @@
*/
namespace Magento\Catalog\Model\ResourceModel\Product\Option;

use Magento\Catalog\Model\Product\Option\Value as OptionValue;
use Magento\Directory\Model\Currency;
use Magento\Directory\Model\CurrencyFactory;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Locale\FormatInterface;
use Magento\Framework\Model\AbstractModel;
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
use Magento\Framework\Model\ResourceModel\Db\Context;
use Magento\Store\Model\ScopeInterface;
use Magento\Store\Model\Store;
use Magento\Store\Model\StoreManagerInterface;

/**
* Catalog product custom option resource model
*
* @author Magento Core Team <[email protected]>
*/
class Value extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
class Value extends AbstractDb
{
/**
* Store manager
*
* @var \Magento\Store\Model\StoreManagerInterface
* @var StoreManagerInterface
*/
protected $_storeManager;

/**
* Currency factory
*
* @var \Magento\Directory\Model\CurrencyFactory
* @var CurrencyFactory
*/
protected $_currencyFactory;

/**
* Core config model
*
* @var \Magento\Framework\App\Config\ScopeConfigInterface
* @var ScopeConfigInterface
*/
protected $_config;

/**
* @var \Magento\Framework\Locale\FormatInterface
* @var FormatInterface
*/
private $localeFormat;

/**
* Class constructor
*
* @param \Magento\Framework\Model\ResourceModel\Db\Context $context
* @param \Magento\Directory\Model\CurrencyFactory $currencyFactory
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Framework\App\Config\ScopeConfigInterface $config
* @param Context $context
* @param CurrencyFactory $currencyFactory
* @param StoreManagerInterface $storeManager
* @param ScopeConfigInterface $config
* @param string $connectionName
*/
public function __construct(
\Magento\Framework\Model\ResourceModel\Db\Context $context,
\Magento\Directory\Model\CurrencyFactory $currencyFactory,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Framework\App\Config\ScopeConfigInterface $config,
Context $context,
CurrencyFactory $currencyFactory,
StoreManagerInterface $storeManager,
ScopeConfigInterface $config,
$connectionName = null
) {
$this->_currencyFactory = $currencyFactory;
Expand All @@ -74,10 +87,10 @@ protected function _construct()
* Proceed operations after object is saved
* Save options store data
*
* @param \Magento\Framework\Model\AbstractModel $object
* @return \Magento\Framework\Model\ResourceModel\Db\AbstractDb
* @param AbstractModel $object
* @return AbstractDb
*/
protected function _afterSave(\Magento\Framework\Model\AbstractModel $object)
protected function _afterSave(AbstractModel $object)
{
$this->_saveValuePrices($object);
$this->_saveValueTitles($object);
Expand All @@ -88,20 +101,21 @@ protected function _afterSave(\Magento\Framework\Model\AbstractModel $object)
/**
* Save option value price data
*
* @param \Magento\Framework\Model\AbstractModel $object
* @param AbstractModel $object
* @return void
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
protected function _saveValuePrices(\Magento\Framework\Model\AbstractModel $object)
protected function _saveValuePrices(AbstractModel $object)
{
$objectPrice = $object->getPrice();
$priceTable = $this->getTable('catalog_product_option_type_price');
$formattedPrice = $this->getLocaleFormatter()->getNumber($object->getPrice());
$formattedPrice = $this->getLocaleFormatter()->getNumber($objectPrice);

$price = (double)sprintf('%F', $formattedPrice);
$priceType = $object->getPriceType();

if ($object->getPrice() && $priceType) {
if (isset($objectPrice) && $priceType) {
//save for store_id = 0
$select = $this->getConnection()->select()->from(
$priceTable,
Expand All @@ -111,7 +125,7 @@ protected function _saveValuePrices(\Magento\Framework\Model\AbstractModel $obje
(int)$object->getId()
)->where(
'store_id = ?',
\Magento\Store\Model\Store::DEFAULT_STORE_ID
Store::DEFAULT_STORE_ID
);
$optionTypeId = $this->getConnection()->fetchOne($select);

Expand All @@ -120,15 +134,15 @@ protected function _saveValuePrices(\Magento\Framework\Model\AbstractModel $obje
$bind = ['price' => $price, 'price_type' => $priceType];
$where = [
'option_type_id = ?' => $optionTypeId,
'store_id = ?' => \Magento\Store\Model\Store::DEFAULT_STORE_ID,
'store_id = ?' => Store::DEFAULT_STORE_ID,
];

$this->getConnection()->update($priceTable, $bind, $where);
}
} else {
$bind = [
'option_type_id' => (int)$object->getId(),
'store_id' => \Magento\Store\Model\Store::DEFAULT_STORE_ID,
'store_id' => Store::DEFAULT_STORE_ID,
'price' => $price,
'price_type' => $priceType,
];
Expand All @@ -137,17 +151,17 @@ protected function _saveValuePrices(\Magento\Framework\Model\AbstractModel $obje
}

$scope = (int)$this->_config->getValue(
\Magento\Store\Model\Store::XML_PATH_PRICE_SCOPE,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
Store::XML_PATH_PRICE_SCOPE,
ScopeInterface::SCOPE_STORE
);

if ($scope == \Magento\Store\Model\Store::PRICE_SCOPE_WEBSITE
if ($scope == Store::PRICE_SCOPE_WEBSITE
&& $priceType
&& $object->getPrice()
&& $object->getStoreId() != \Magento\Store\Model\Store::DEFAULT_STORE_ID
&& isset($objectPrice)
&& $object->getStoreId() != Store::DEFAULT_STORE_ID
) {
$baseCurrency = $this->_config->getValue(
\Magento\Directory\Model\Currency::XML_PATH_CURRENCY_BASE,
Currency::XML_PATH_CURRENCY_BASE,
'default'
);

Expand All @@ -156,7 +170,7 @@ protected function _saveValuePrices(\Magento\Framework\Model\AbstractModel $obje
foreach ($storeIds as $storeId) {
if ($priceType == 'fixed') {
$storeCurrency = $this->_storeManager->getStore($storeId)->getBaseCurrencyCode();
/** @var $currencyModel \Magento\Directory\Model\Currency */
/** @var $currencyModel Currency */
$currencyModel = $this->_currencyFactory->create();
$currencyModel->load($baseCurrency);
$rate = $currencyModel->getRate($storeCurrency);
Expand Down Expand Up @@ -198,8 +212,8 @@ protected function _saveValuePrices(\Magento\Framework\Model\AbstractModel $obje
}
}
} else {
if ($scope == \Magento\Store\Model\Store::PRICE_SCOPE_WEBSITE
&& !$object->getPrice()
if ($scope == Store::PRICE_SCOPE_WEBSITE
&& !isset($objectPrice)
&& !$priceType
) {
$storeIds = $this->_storeManager->getStore($object->getStoreId())->getWebsite()->getStoreIds();
Expand All @@ -217,13 +231,13 @@ protected function _saveValuePrices(\Magento\Framework\Model\AbstractModel $obje
/**
* Save option value title data
*
* @param \Magento\Framework\Model\AbstractModel $object
* @param AbstractModel $object
* @return void
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
protected function _saveValueTitles(\Magento\Framework\Model\AbstractModel $object)
protected function _saveValueTitles(AbstractModel $object)
{
foreach ([\Magento\Store\Model\Store::DEFAULT_STORE_ID, $object->getStoreId()] as $storeId) {
foreach ([Store::DEFAULT_STORE_ID, $object->getStoreId()] as $storeId) {
$titleTable = $this->getTable('catalog_product_option_type_title');
$select = $this->getConnection()->select()->from(
$titleTable,
Expand All @@ -238,7 +252,7 @@ protected function _saveValueTitles(\Magento\Framework\Model\AbstractModel $obje
$optionTypeId = $this->getConnection()->fetchOne($select);
$existInCurrentStore = $this->getOptionIdFromOptionTable($titleTable, (int)$object->getId(), (int)$storeId);

if ($storeId != \Magento\Store\Model\Store::DEFAULT_STORE_ID && $object->getData('is_delete_store_title')) {
if ($storeId != Store::DEFAULT_STORE_ID && $object->getData('is_delete_store_title')) {
$object->unsetData('title');
}

Expand All @@ -256,11 +270,11 @@ protected function _saveValueTitles(\Magento\Framework\Model\AbstractModel $obje
$existInDefaultStore = $this->getOptionIdFromOptionTable(
$titleTable,
(int)$object->getId(),
\Magento\Store\Model\Store::DEFAULT_STORE_ID
Store::DEFAULT_STORE_ID
);
// we should insert record into not default store only of if it does not exist in default store
if (($storeId == \Magento\Store\Model\Store::DEFAULT_STORE_ID && !$existInDefaultStore)
|| ($storeId != \Magento\Store\Model\Store::DEFAULT_STORE_ID && !$existInCurrentStore)
if (($storeId == Store::DEFAULT_STORE_ID && !$existInDefaultStore)
|| ($storeId != Store::DEFAULT_STORE_ID && !$existInCurrentStore)
) {
$bind = [
'option_type_id' => (int)$object->getId(),
Expand All @@ -273,7 +287,7 @@ protected function _saveValueTitles(\Magento\Framework\Model\AbstractModel $obje
} else {
if ($storeId
&& $optionTypeId
&& $object->getStoreId() > \Magento\Store\Model\Store::DEFAULT_STORE_ID
&& $object->getStoreId() > Store::DEFAULT_STORE_ID
) {
$where = [
'option_type_id = ?' => (int)$optionTypeId,
Expand Down Expand Up @@ -353,12 +367,12 @@ public function deleteValues($optionTypeId)
/**
* Duplicate product options value
*
* @param \Magento\Catalog\Model\Product\Option\Value $object
* @param OptionValue $object
* @param int $oldOptionId
* @param int $newOptionId
* @return \Magento\Catalog\Model\Product\Option\Value
* @return OptionValue
*/
public function duplicate(\Magento\Catalog\Model\Product\Option\Value $object, $oldOptionId, $newOptionId)
public function duplicate(OptionValue $object, $oldOptionId, $newOptionId)
{
$connection = $this->getConnection();
$select = $connection->select()->from($this->getMainTable())->where('option_id = ?', $oldOptionId);
Expand Down Expand Up @@ -425,14 +439,14 @@ public function duplicate(\Magento\Catalog\Model\Product\Option\Value $object, $
/**
* Get FormatInterface to convert price from string to number format
*
* @return \Magento\Framework\Locale\FormatInterface
* @return FormatInterface
* @deprecated 101.0.8
*/
private function getLocaleFormatter()
{
if ($this->localeFormat === null) {
$this->localeFormat = \Magento\Framework\App\ObjectManager::getInstance()
->get(\Magento\Framework\Locale\FormatInterface::class);
$this->localeFormat = ObjectManager::getInstance()
->get(FormatInterface::class);
}
return $this->localeFormat;
}
Expand Down
2 changes: 0 additions & 2 deletions app/code/Magento/CatalogSearch/etc/indexer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
<indexer id="catalogsearch_fulltext" view_id="catalogsearch_fulltext" class="Magento\CatalogSearch\Model\Indexer\Fulltext">
<title translate="true">Catalog Search</title>
<description translate="true">Rebuild Catalog product fulltext search index</description>

<saveHandler class="Magento\CatalogSearch\Model\Indexer\IndexHandler" />
<structure class="Magento\CatalogSearch\Model\Indexer\IndexStructure" />
</indexer>
</config>
6 changes: 3 additions & 3 deletions app/code/Magento/Cms/Model/ResourceModel/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,10 @@ public function getIsUniqueBlockToStores(AbstractModel $object)
$entityMetadata = $this->metadataPool->getMetadata(BlockInterface::class);
$linkField = $entityMetadata->getLinkField();

if ($this->_storeManager->hasSingleStore()) {
if ($this->_storeManager->isSingleStoreMode()) {
$stores = [Store::DEFAULT_STORE_ID];
} else {
$stores = (array)$object->getData('stores');
$stores = (array)$object->getData('store_id');
}

$select = $this->getConnection()->select()
Expand Down Expand Up @@ -230,7 +230,7 @@ public function lookupStoreIds($id)
'cbs.' . $linkField . ' = cb.' . $linkField,
[]
)
->where('cb.' . $entityMetadata->getIdentifierField() . ' = :block_id');
->where('cb.' . $entityMetadata->getIdentifierField() . ' = :block_id');

return $connection->fetchCol($select, ['block_id' => (int)$id]);
}
Expand Down
1 change: 1 addition & 0 deletions app/code/Magento/Sales/Model/AdminOrder/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -1907,6 +1907,7 @@ public function createOrder()
$oldOrder = $this->getSession()->getOrder();
$oldOrder->setRelationChildId($order->getId());
$oldOrder->setRelationChildRealId($order->getIncrementId());
$oldOrder->save();
$this->orderManagement->cancel($oldOrder->getEntityId());
$order->save();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@
<settings>
<filter>text</filter>
<label translate="true">ID</label>
<sorting>desc</sorting>
</settings>
</column>
<column name="store_id" class="Magento\Store\Ui\Component\Listing\Column\Store">
Expand All @@ -154,6 +153,7 @@
<filter>dateRange</filter>
<dataType>date</dataType>
<label translate="true">Purchase Date</label>
<sorting>desc</sorting>
</settings>
</column>
<column name="billing_name">
Expand Down
11 changes: 9 additions & 2 deletions app/code/Magento/Security/Model/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,17 @@ class Config implements ConfigInterface
*/
const XML_PATH_ADMIN_AREA = 'admin/security/';

/**
* Configuration path to frontend area
*/
const XML_PATH_FRONTEND_AREA = 'customer/password/';

/**
* Configuration path to fronted area
* @deprecated
* @see \Magento\Security\Model\Config::XML_PATH_FRONTEND_AREA
*/
const XML_PATH_FRONTED_AREA = 'customer/password/';
const XML_PATH_FRONTED_AREA = self::XML_PATH_FRONTEND_AREA;

/**
* Configuration path to admin account sharing
Expand Down Expand Up @@ -134,7 +141,7 @@ protected function getXmlPathPrefix()
if ($this->scope->getCurrentScope() == \Magento\Framework\App\Area::AREA_ADMINHTML) {
return self::XML_PATH_ADMIN_AREA;
}
return self::XML_PATH_FRONTED_AREA;
return self::XML_PATH_FRONTEND_AREA;
}

/**
Expand Down
Loading

0 comments on commit befe833

Please sign in to comment.