Skip to content

Commit

Permalink
ENGCOM-4345: Fixed: #21278, Add sort order on downloadable links #21279
Browse files Browse the repository at this point in the history
 - Merge Pull Request #21279 from maheshWebkul721/magento2:add-sort-order-downloadable-links
 - Merged commits:
   1. c9a9d64
   2. 92d2a3c
   3. 03f0c3a
   4. 81a4de8
  • Loading branch information
magento-engcom-team committed Mar 4, 2019
2 parents c11f507 + 81a4de8 commit 2b0cece
Show file tree
Hide file tree
Showing 364 changed files with 12,803 additions and 1,809 deletions.
6 changes: 3 additions & 3 deletions app/code/Magento/AdvancedSearch/etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,18 @@
</depends>
</field>
<!--<group id="suggestions">-->
<field id="search_suggestion_enabled" translate="label comment" type="select" sortOrder="70" showInDefault="1" showInWebsite="1" showInStore="1">
<field id="search_suggestion_enabled" translate="label comment" type="select" sortOrder="90" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enable Search Suggestions</label>
<comment>When you enable this option your site may slow down.</comment>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="search_suggestion_count" translate="label" type="text" sortOrder="71" showInDefault="1" showInWebsite="1" showInStore="1">
<field id="search_suggestion_count" translate="label" type="text" sortOrder="91" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Search Suggestions Count</label>
<depends>
<field id="search_suggestion_enabled">1</field>
</depends>
</field>
<field id="search_suggestion_count_results_enabled" translate="label" type="select" sortOrder="72" showInDefault="1" showInWebsite="1" showInStore="1">
<field id="search_suggestion_count_results_enabled" translate="label" type="select" sortOrder="92" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Show Results Count for Each Suggestion</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<comment>When you enable this option your site may slow down.</comment>
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/AuthorizenetAcceptjs/etc/payment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Payment:etc/payment.xsd">
<methods>
<method name="authorizenet_acceptjs">
<allow_multiple_address>1</allow_multiple_address>
<allow_multiple_address>0</allow_multiple_address>
</method>
</methods>
</payment>
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,10 @@
*/

var config = {
shim: {
acceptjs: {
exports: 'Accept'
},
acceptjssandbox: {
exports: 'Accept'
map: {
'*': {
acceptjssandbox: 'https://jstest.authorize.net/v1/Accept.js',
acceptjs: 'https://js.authorize.net/v1/Accept.js'
}
},
paths: {
acceptjssandbox: 'https://jstest.authorize.net/v1/Accept',
acceptjs: 'https://js.authorize.net/v1/Accept'
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ define([
dependency = 'acceptjssandbox';
}

require([dependency], function (accept) {
require([dependency], function () {
var $body = $('body');

/*
Expand All @@ -26,7 +26,16 @@ define([
* Dynamically-loading-Accept-js-E-WC-03-Accept-js-is-not-loaded/td-p/63283
*/
$body.on('handshake.acceptjs', function () {
deferred.resolve(accept);
/*
* Accept.js doesn't return the library when loading
* and requirejs "shim" can't be used because it only works with the "paths" config option
* and we can't use "paths" because require will try to load ".min.js" in production
* and that doesn't work because it doesn't exist
* and we can't add a query string to force a URL because accept.js will reject it
* and we can't include it locally because they check in the script before loading more scripts
* So, we use the global version as "shim" would
*/
deferred.resolve(window.Accept);
$body.off('handshake.acceptjs');
});
},
Expand Down
4 changes: 3 additions & 1 deletion app/code/Magento/Backend/Model/Session/Quote.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
* @method Quote setOrderId($orderId)
* @method int getOrderId()
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
* @since 100.0.2
*/
class Quote extends \Magento\Framework\Session\SessionManager
Expand Down Expand Up @@ -149,7 +150,8 @@ public function getQuote()
$this->_quote = $this->quoteFactory->create();
if ($this->getStoreId()) {
if (!$this->getQuoteId()) {
$this->_quote->setCustomerGroupId($this->groupManagement->getDefaultGroup()->getId());
$customerGroupId = $this->groupManagement->getDefaultGroup($this->getStoreId())->getId();
$this->_quote->setCustomerGroupId($customerGroupId);
$this->_quote->setIsActive(false);
$this->_quote->setStoreId($this->getStoreId());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,10 @@ public function testGetQuoteWithoutQuoteId()
$cartInterfaceMock->expects($this->atLeastOnce())->method('getId')->willReturn($quoteId);
$defaultGroup = $this->getMockBuilder(\Magento\Customer\Api\Data\GroupInterface::class)->getMock();
$defaultGroup->expects($this->any())->method('getId')->will($this->returnValue($customerGroupId));
$this->groupManagementMock->expects($this->any())->method('getDefaultGroup')->willReturn($defaultGroup);
$this->groupManagementMock
->method('getDefaultGroup')
->with($storeId)
->willReturn($defaultGroup);

$dataCustomerMock = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class)
->disableOriginalConstructor()
Expand Down
4 changes: 2 additions & 2 deletions app/code/Magento/Backend/etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
<group id="debug" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Debug</label>
<field id="template_hints_storefront" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enabled Template Path Hints for Storefront</label>
<label>Enable Template Path Hints for Storefront</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="template_hints_storefront_show_with_parameter" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
Expand All @@ -132,7 +132,7 @@
<comment>Add the following parameter to the URL to show template hints ?templatehints=[parameter_value]</comment>
</field>
<field id="template_hints_admin" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Enabled Template Path Hints for Admin</label>
<label>Enable Template Path Hints for Admin</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="template_hints_blocks" translate="label" type="select" sortOrder="21" showInDefault="1" showInWebsite="1" showInStore="1">
Expand Down
3 changes: 1 addition & 2 deletions app/code/Magento/Backup/Controller/Adminhtml/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
namespace Magento\Backup\Controller\Adminhtml;

use Magento\Backend\App\Action;
use Magento\Framework\App\Action\HttpGetActionInterface;
use Magento\Backup\Helper\Data as Helper;
use Magento\Framework\App\ObjectManager;

Expand All @@ -18,7 +17,7 @@
* @since 100.0.2
* @SuppressWarnings(PHPMD.AllPurposeAction)
*/
abstract class Index extends Action implements HttpGetActionInterface
abstract class Index extends Action
{
/**
* Authorization level of a basic admin session
Expand Down
7 changes: 5 additions & 2 deletions app/code/Magento/Backup/Controller/Adminhtml/Index/Create.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
<?php
/**
*
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Backup\Controller\Adminhtml\Index;

use Magento\Framework\App\Action\HttpPostActionInterface;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Filesystem;

class Create extends \Magento\Backup\Controller\Adminhtml\Index
/**
* Create backup controller
*/
class Create extends \Magento\Backup\Controller\Adminhtml\Index implements HttpPostActionInterface
{
/**
* Create backup action.
Expand Down
29 changes: 25 additions & 4 deletions app/code/Magento/Backup/Model/Db.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
namespace Magento\Backup\Model;

use Magento\Backup\Helper\Data as Helper;
use Magento\Backup\Model\ResourceModel\Table\GetListTables;
use Magento\Backup\Model\ResourceModel\View\CreateViewsBackup;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Exception\RuntimeException;

Expand Down Expand Up @@ -44,18 +46,35 @@ class Db implements \Magento\Framework\Backup\Db\BackupDbInterface
private $helper;

/**
* @param \Magento\Backup\Model\ResourceModel\Db $resourceDb
* @var GetListTables
*/
private $getListTables;

/**
* @var CreateViewsBackup
*/
private $getViewsBackup;

/**
* Db constructor.
* @param ResourceModel\Db $resourceDb
* @param \Magento\Framework\App\ResourceConnection $resource
* @param Helper|null $helper
* @param GetListTables|null $getListTables
* @param CreateViewsBackup|null $getViewsBackup
*/
public function __construct(
\Magento\Backup\Model\ResourceModel\Db $resourceDb,
ResourceModel\Db $resourceDb,
\Magento\Framework\App\ResourceConnection $resource,
?Helper $helper = null
?Helper $helper = null,
?GetListTables $getListTables = null,
?CreateViewsBackup $getViewsBackup = null
) {
$this->_resourceDb = $resourceDb;
$this->_resource = $resource;
$this->helper = $helper ?? ObjectManager::getInstance()->get(Helper::class);
$this->getListTables = $getListTables ?? ObjectManager::getInstance()->get(GetListTables::class);
$this->getViewsBackup = $getViewsBackup ?? ObjectManager::getInstance()->get(CreateViewsBackup::class);
}

/**
Expand Down Expand Up @@ -161,7 +180,7 @@ public function createBackup(\Magento\Framework\Backup\Db\BackupInterface $backu

$this->getResource()->beginTransaction();

$tables = $this->getResource()->getTables();
$tables = $this->getListTables->execute();

$backup->write($this->getResource()->getHeader());

Expand Down Expand Up @@ -198,6 +217,8 @@ public function createBackup(\Magento\Framework\Backup\Db\BackupInterface $backu
$backup->write($this->getResource()->getTableDataAfterSql($table));
}
}
$this->getViewsBackup->execute($backup);

$backup->write($this->getResource()->getTableForeignKeysSql());
$backup->write($this->getResource()->getTableTriggersSql());
$backup->write($this->getResource()->getFooter());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Backup\Model\ResourceModel\Table;

use Magento\Framework\App\ResourceConnection;

/**
* Provides full list of tables in the database. This list excludes views, to allow different backup process.
*/
class GetListTables
{
private const TABLE_TYPE = 'BASE TABLE';

/**
* @var ResourceConnection
*/
private $resource;

/**
* @param ResourceConnection $resource
*/
public function __construct(ResourceConnection $resource)
{
$this->resource = $resource;
}

/**
* Get list of database tables excluding views.
*
* @return array
*/
public function execute(): array
{
return $this->resource->getConnection('backup')->fetchCol(
"SHOW FULL TABLES WHERE `Table_type` = ?",
self::TABLE_TYPE
);
}
}
116 changes: 116 additions & 0 deletions app/code/Magento/Backup/Model/ResourceModel/View/CreateViewsBackup.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Backup\Model\ResourceModel\View;

use Magento\Framework\App\ResourceConnection;
use Magento\Framework\Backup\Db\BackupInterface;
use Magento\Framework\DB\Adapter\AdapterInterface;

/**
* Creates backup of Views in the database.
*/
class CreateViewsBackup
{
/**
* @var GetListViews
*/
private $getListViews;

/**
* @var ResourceConnection
*/
private $resourceConnection;

/**
* @var AdapterInterface
*/
private $connection;

/**
* @param GetListViews $getListViews
* @param ResourceConnection $resourceConnection
*/
public function __construct(
GetListViews $getListViews,
ResourceConnection $resourceConnection
) {
$this->getListViews = $getListViews;
$this->resourceConnection = $resourceConnection;
}

/**
* Write backup data to backup file.
*
* @param BackupInterface $backup
*/
public function execute(BackupInterface $backup): void
{
$views = $this->getListViews->execute();

foreach ($views as $view) {
$backup->write($this->getViewHeader($view));
$backup->write($this->getDropViewSql($view));
$backup->write($this->getCreateView($view));
}
}

/**
* Retrieve Database connection for Backup.
*
* @return AdapterInterface
*/
private function getConnection(): AdapterInterface
{
if (!$this->connection) {
$this->connection = $this->resourceConnection->getConnection('backup');
}

return $this->connection;
}

/**
* Get CREATE VIEW query for the specific view.
*
* @param string $viewName
* @return string
*/
private function getCreateView(string $viewName): string
{
$quotedViewName = $this->getConnection()->quoteIdentifier($viewName);
$query = 'SHOW CREATE VIEW ' . $quotedViewName;
$row = $this->getConnection()->fetchRow($query);
$regExp = '/\sDEFINER\=\`([^`]*)\`\@\`([^`]*)\`/';
$sql = preg_replace($regExp, '', $row['Create View']);

return $sql . ';' . "\n";
}

/**
* Prepare a header for View being dumped.
*
* @param string $viewName
* @return string
*/
public function getViewHeader(string $viewName): string
{
$quotedViewName = $this->getConnection()->quoteIdentifier($viewName);
return "\n--\n" . "-- Structure for view {$quotedViewName}\n" . "--\n\n";
}

/**
* Make sure that View being created is deleted if already exists.
*
* @param string $viewName
* @return string
*/
public function getDropViewSql(string $viewName): string
{
$quotedViewName = $this->getConnection()->quoteIdentifier($viewName);
return sprintf('DROP VIEW IF EXISTS %s;\n', $quotedViewName);
}
}
Loading

0 comments on commit 2b0cece

Please sign in to comment.