Skip to content

Commit

Permalink
#26986 Fix Static checks for Collection file
Browse files Browse the repository at this point in the history
  • Loading branch information
lbajsarowicz committed Feb 24, 2020
1 parent e001493 commit ecb3a8d
Showing 1 changed file with 21 additions and 39 deletions.
60 changes: 21 additions & 39 deletions app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Magento\Catalog\Model\Indexer\Product\Price\PriceTableResolver;
use Magento\Catalog\Model\Product\Attribute\Source\Status as ProductStatus;
use Magento\Catalog\Model\Product\Gallery\ReadHandler as GalleryReadHandler;
use Magento\Catalog\Model\ResourceModel\Category;
use Magento\Catalog\Model\ResourceModel\Product\Collection\ProductLimitationFactory;
use Magento\CatalogUrlRewrite\Model\ProductUrlRewriteGenerator;
use Magento\CatalogUrlRewrite\Model\Storage\DbStorage;
Expand All @@ -23,7 +24,6 @@
use Magento\Framework\Indexer\DimensionFactory;
use Magento\Store\Model\Indexer\WebsiteDimensionProvider;
use Magento\Store\Model\Store;
use Magento\Catalog\Model\ResourceModel\Category;

/**
* Product collection
Expand Down Expand Up @@ -1013,9 +1013,9 @@ public function getMaxAttributeValue($attribute)
$tableAlias = $attributeCode . '_max_value';
$fieldAlias = 'max_' . $attributeCode;
$condition = 'e.entity_id = ' . $tableAlias . '.entity_id AND ' . $this->_getConditionSql(
$tableAlias . '.attribute_id',
$attribute->getId()
);
$tableAlias . '.attribute_id',
$attribute->getId()
);

$select->join(
[$tableAlias => $attribute->getBackend()->getTable()],
Expand Down Expand Up @@ -1048,9 +1048,9 @@ public function getAttributeValueCountByRange($attribute, $range)
$tableAlias = $attributeCode . '_range_count_value';

$condition = 'e.entity_id = ' . $tableAlias . '.entity_id AND ' . $this->_getConditionSql(
$tableAlias . '.attribute_id',
$attribute->getId()
);
$tableAlias . '.attribute_id',
$attribute->getId()
);

$select->reset(\Magento\Framework\DB\Select::GROUP);
$select->join(
Expand Down Expand Up @@ -1088,9 +1088,9 @@ public function getAttributeValueCount($attribute)

$select->reset(\Magento\Framework\DB\Select::GROUP);
$condition = 'e.entity_id=' . $tableAlias . '.entity_id AND ' . $this->_getConditionSql(
$tableAlias . '.attribute_id',
$attribute->getId()
);
$tableAlias . '.attribute_id',
$attribute->getId()
);

$select->join(
[$tableAlias => $attribute->getBackend()->getTable()],
Expand Down Expand Up @@ -1783,30 +1783,19 @@ public function addAttributeToSort($attribute, $dir = self::SORT_ORDER_ASC)
*/
protected function _prepareProductLimitationFilters()
{
if (isset(
$this->_productLimitationFilters['visibility']
) && !isset(
$this->_productLimitationFilters['store_id']
)
) {
if (isset($this->_productLimitationFilters['visibility'])
&& !isset($this->_productLimitationFilters['store_id'])) {
$this->_productLimitationFilters['store_id'] = $this->getStoreId();
}
if (isset(
$this->_productLimitationFilters['category_id']
) && !isset(
$this->_productLimitationFilters['store_id']
)
) {

if (isset($this->_productLimitationFilters['category_id'])
&& !isset($this->_productLimitationFilters['store_id'])) {
$this->_productLimitationFilters['store_id'] = $this->getStoreId();
}
if (isset(
$this->_productLimitationFilters['store_id']
) && isset(
$this->_productLimitationFilters['visibility']
) && !isset(
$this->_productLimitationFilters['category_id']
)
) {

if (isset($this->_productLimitationFilters['store_id'])
&& isset($this->_productLimitationFilters['visibility'])
&& !isset($this->_productLimitationFilters['category_id'])) {
$this->_productLimitationFilters['category_id'] = $this->_storeManager->getStore(
$this->_productLimitationFilters['store_id']
)->getRootCategoryId();
Expand Down Expand Up @@ -1837,14 +1826,8 @@ protected function _productLimitationJoinWebsite()
$filters['website_ids'],
'int'
);
} elseif (isset(
$filters['store_id']
) && (!isset(
$filters['visibility']
) && !isset(
$filters['category_id']
)) && !$this->isEnabledFlat()
) {
} elseif (isset($filters['store_id']) && !$this->isEnabledFlat()
&& (!isset($filters['visibility']) && !isset($filters['category_id']))) {
$joinWebsite = true;
$websiteId = $this->_storeManager->getStore($filters['store_id'])->getWebsiteId();
$conditions[] = $this->getConnection()->quoteInto('product_website.website_id = ?', $websiteId, 'int');
Expand Down Expand Up @@ -2431,7 +2414,6 @@ private function getGalleryReadHandler()
*
* @return \Magento\Catalog\Model\ResourceModel\Product\Gallery
* @deprecated 101.0.1
*
*/
private function getMediaGalleryResource()
{
Expand Down

0 comments on commit ecb3a8d

Please sign in to comment.