Skip to content

Commit

Permalink
Merge pull request #624 from magento-fearless-kiwis/develop
Browse files Browse the repository at this point in the history
 [FearlessKiwis] Bug fixes
  • Loading branch information
monkeysee committed May 17, 2016
2 parents a5be15b + 3b770f7 commit bac009a
Show file tree
Hide file tree
Showing 11 changed files with 133 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ protected function _prepareIndex($entityIds = null, $attributeId = null)
* @param array $entityIds the entity ids limitation
* @param int $attributeId the attribute id limitation
* @return $this
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
protected function _prepareSelectIndex($entityIds = null, $attributeId = null)
{
Expand All @@ -125,31 +126,37 @@ protected function _prepareSelectIndex($entityIds = null, $attributeId = null)
['s' => $this->getTable('store')],
['store_id', 'website_id']
)->joinLeft(
['d' => $this->getTable('catalog_product_entity_int')],
'd.store_id = 0 OR d.store_id = s.store_id',
['attribute_id', 'value']
['dd' => $this->getTable('catalog_product_entity_int')],
'dd.store_id = 0',
['attribute_id']
)->joinLeft(
['d2' => $this->getTable('catalog_product_entity_int')],
['ds' => $this->getTable('catalog_product_entity_int')],
"ds.store_id = s.store_id AND ds.attribute_id = dd.attribute_id AND " .
"ds.{$productIdField} = dd.{$productIdField}",
['value' => new \Zend_Db_Expr('COALESCE(ds.value, dd.value)')]
)->joinLeft(
['d2d' => $this->getTable('catalog_product_entity_int')],
sprintf(
"d.{$productIdField} = d2.{$productIdField}"
. ' AND d2.attribute_id = %s AND d2.value = %s AND d.store_id = d2.store_id',
$this->_eavConfig->getAttribute(\Magento\Catalog\Model\Product::ENTITY, 'status')->getId(),
ProductStatus::STATUS_ENABLED
"d2d.store_id = 0 AND d2d.{$productIdField} = dd.{$productIdField} AND d2d.attribute_id = %s",
$this->_eavConfig->getAttribute(\Magento\Catalog\Model\Product::ENTITY, 'status')->getId()
),
[]
)->joinLeft(
['d2s' => $this->getTable('catalog_product_entity_int')],
"d2s.store_id = s.store_id AND d2s.attribute_id = d2d.attribute_id AND " .
"d2s.{$productIdField} = d2d.{$productIdField}",
[]
)->joinLeft(
['cpe' => $this->getTable('catalog_product_entity')],
"cpe.{$productIdField} = d.{$productIdField}",
"cpe.{$productIdField} = dd.{$productIdField}",
array_unique([$productIdField, 'entity_id'])
)->where(
's.store_id != 0'
)->where(
'd.value IS NOT NULL'
'(ds.value IS NOT NULL OR dd.value IS NOT NULL)'
)->where(
'd2.value IS NOT NULL'
)->group([
's.store_id', 's.website_id', 'cpe.entity_id', 'd.attribute_id', 'd.value',
]);
(new \Zend_Db_Expr('COALESCE(d2s.value, d2d.value)')) . ' = ' . ProductStatus::STATUS_ENABLED
)->distinct(true);

if ($entityIds !== null) {
$subSelect->where('cpe.entity_id IN(?)', $entityIds);
Expand Down
49 changes: 48 additions & 1 deletion app/code/Magento/Catalog/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -715,16 +715,63 @@
</argument>
</arguments>
</type>
<virtualType name="Magento\Catalog\EntityCreator\MetadataPool" type="Magento\Framework\EntityManager\MetadataPool">
<arguments>
<argument name="metadata" xsi:type="array">
<item name="Magento\Catalog\Api\Data\ProductInterface" xsi:type="array">
<item name="entityContext" xsi:type="array">
<item name="store" xsi:type="string">Magento\Store\Model\DefaultStoreScopeProvider</item>
</item>
</item>
<item name="Magento\Catalog\Api\Data\CategoryInterface" xsi:type="array">
<item name="entityContext" xsi:type="array">
<item name="store" xsi:type="string">Magento\Store\Model\DefaultStoreScopeProvider</item>
</item>
</item>
<item name="Magento\Catalog\Api\Data\CategoryTreeInterface" xsi:type="array">
<item name="entityContext" xsi:type="array">
<item name="store" xsi:type="string">Magento\Store\Model\DefaultStoreScopeProvider</item>
</item>
</item>
</argument>
</arguments>
</virtualType>
<virtualType name="Magento\Catalog\Model\Entity\CreationScopeResolver" type="Magento\Framework\Model\Entity\ScopeResolver">
<arguments>
<argument name="metadataPool" xsi:type="object">Magento\Catalog\EntityCreator\MetadataPool</argument>
</arguments>
</virtualType>
<virtualType name="Magento\Catalog\Model\ResourceModel\CreateHandler" type="Magento\Eav\Model\ResourceModel\CreateHandler">
<arguments>
<argument name="attributePersistor" xsi:type="object">Magento\Catalog\Model\ResourceModel\AttributePersistor</argument>
<argument name="metadataPool" xsi:type="object">Magento\Catalog\EntityCreator\MetadataPool</argument>
<argument name="scopeResolver" xsi:type="object">Magento\Catalog\Model\Entity\CreationScopeResolver</argument>
</arguments>
</virtualType>
<virtualType name="Magento\Catalog\Model\ResourceModel\UpdateHandler" type="Magento\Eav\Model\ResourceModel\UpdateHandler">
<arguments>
<argument name="attributePersistor" xsi:type="object">Magento\Catalog\Model\ResourceModel\AttributePersistor</argument>
</arguments>
</virtualType>
<type name="Magento\Framework\EntityManager\Operation\AttributePool">
<arguments>
<argument name="extensionActions" xsi:type="array">
<item name="eav" xsi:type="array">
<item name="Magento\Catalog\Api\Data\CategoryTreeInterface" xsi:type="array">
<item name="create" xsi:type="string">Magento\Catalog\Model\ResourceModel\CreateHandler</item>
<item name="update" xsi:type="string">Magento\Catalog\Model\ResourceModel\UpdateHandler</item>
</item>
<item name="Magento\Catalog\Api\Data\CategoryInterface" xsi:type="array">
<item name="create" xsi:type="string">Magento\Catalog\Model\ResourceModel\CreateHandler</item>
<item name="update" xsi:type="string">Magento\Catalog\Model\ResourceModel\UpdateHandler</item>
</item>
<item name="Magento\Catalog\Api\Data\ProductInterface" xsi:type="array">
<item name="create" xsi:type="string">Magento\Catalog\Model\ResourceModel\CreateHandler</item>
<item name="update" xsi:type="string">Magento\Catalog\Model\ResourceModel\UpdateHandler</item>
</item>
</item>
</argument>
</arguments>
</type>
<type name="Magento\Framework\EntityManager\HydratorPool">
<arguments>
<argument name="hydrators" xsi:type="array">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,6 @@ public function getColumnHtml(\Magento\Framework\DataObject $item, $column, $fie
case 'price-original':
$html = $this->displayPriceAttribute('original_price');
break;
case 'price':
$html = $this->displayPriceAttribute('price');
break;
case 'tax-amount':
$html = $this->displayPriceAttribute('tax_amount');
break;
Expand Down
45 changes: 45 additions & 0 deletions app/code/Magento/Store/Model/DefaultStoreScopeProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Store\Model;

use Magento\Framework\Model\Entity\ScopeProviderInterface;
use Magento\Store\Model\Store;
use Magento\Framework\Model\Entity\ScopeFactory;

/**
* Class StoreScope
*/
class DefaultStoreScopeProvider implements ScopeProviderInterface
{

/**
* @var ScopeFactory
*/
private $scopeFactory;

/**
* StoreScopeProvider constructor.
*
* @param ScopeFactory $scopeFactory
*/
public function __construct(
ScopeFactory $scopeFactory
) {
$this->scopeFactory = $scopeFactory;
}

/**
* @param string $entityType
* @param array $entityData
* @return \Magento\Framework\Model\Entity\ScopeInterface
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function getContext($entityType, $entityData = [])
{
return $this->scopeFactory->create(Store::STORE_ID, Store::DEFAULT_STORE_ID, null);
}
}
4 changes: 1 addition & 3 deletions app/code/Magento/Store/Model/StoreScopeProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public function __construct(
* @param string $entityType
* @param array $entityData
* @return \Magento\Framework\Model\Entity\ScopeInterface
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function getContext($entityType, $entityData = [])
{
Expand All @@ -54,9 +55,6 @@ public function getContext($entityType, $entityData = [])

$identifier = Store::STORE_ID;
$fallback = null;
if ($value == 1) {
$value = 0;
}
if ($value != Store::DEFAULT_STORE_ID) {
$fallback = $this->scopeFactory->create($identifier, Store::DEFAULT_STORE_ID);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ public function save()
*/
public function delete()
{
$this->waitBeforeClick();
$this->_rootElement->find($this->deleteButton)->click();
}

Expand All @@ -139,6 +140,6 @@ public function checkDeleteButton()
protected function waitBeforeClick()
{
time_nanosleep(0, 600000000);
usleep(500000);
usleep(1000000);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<data name="customer/dataset" xsi:type="string">johndoe_unique</data>
<data name="salesRule" xsi:type="string">active_sales_rule_for_all_groups_no_coupon</data>
<data name="catalogRule" xsi:type="string">-</data>
<data name="configData" xsi:type="string">display_excluding_including_tax</data>
<data name="configData" xsi:type="string">total_cat_excl_ship_incl_after_disc_on_excl, display_excluding_including_tax</data>
<data name="qty" xsi:type="string">3</data>
<data name="prices/category_price_excl_tax" xsi:type="string">1.00</data>
<data name="prices/category_price_incl_tax" xsi:type="string">1.10</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public function run()
{
$result['salesRule'] = null;
if ($this->salesRule !== null) {
$this->deleteAllSalesRule->run();
$salesRule = $this->fixtureFactory->createByCode(
'salesRule',
['dataset' => $this->salesRule]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public function processAssert(
$this->orderInvoiceNew = $orderInvoiceNew;
$this->orderCreditMemoNew = $orderCreditMemoNew;
$orderIndex->open();
$this->waitBeforeClick();
$orderIndex->getSalesOrderGrid()->openFirstRow();
//Check prices on order page
$actualPrices = [];
Expand Down Expand Up @@ -222,4 +223,15 @@ public function toString()
{
return 'Prices on backend after order creation is correct.';
}

/**
* Wait for User before click
*
* @return void
*/
protected function waitBeforeClick()
{
time_nanosleep(0, 600000000);
usleep(1000000);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public function run()
{
$result['taxRule'] = null;
if ($this->taxRule !== null) {
$this->deleteAllTaxRule->run();
$taxRuleDataSets = explode(',', $this->taxRule);
foreach ($taxRuleDataSets as $taxRuleDataSet) {
$taxRule = $this->fixtureFactory->createByCode(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@
->setDefaultSortBy($data['default_sort_by'])
->setIsActive($data['is_active'])
->setPosition($data['position'])
->setStoreId(0)
->save();
}

0 comments on commit bac009a

Please sign in to comment.