Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update fixing bug in 2.1.8 and fixing NULL instead of 0 #5

Merged
merged 1 commit into from
Dec 23, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions Model/ResourceModel/ProductVisibilityGrid/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,17 @@ public function prepareCollection()
['in_website' => new \Zend_Db_Expr('product_website.product_id IS NOT NULL')]
);

$categoryTable = $this->getTable('catalog_category_product_index_store') . $store->getId();

if ($this->getConnection()->isTableExists($categoryTable)) {
// Use the one above
} else {
$categoryTable = $this->getTable('catalog_category_product_index');
}

// Join with category product link table.
$select->joinLeft(
['category_product' => $this->getTable('catalog_category_product_index_store' . $store->getId())],
['category_product' => $categoryTable],
'category_product.product_id = main_table.entity_id'
. ' AND category_product.category_id = \'' . $store->getRootCategoryId() . '\''
. ' AND category_product.store_id = \'' . $this->storeId . '\''
Expand Down Expand Up @@ -206,9 +214,9 @@ protected function addCategoryVisibility()
$this->productCollection->getSelect()
->reset(\Zend_Db_Select::COLUMNS)
->columns(['p_entity_id' => 'e.entity_id'])
->columns(['is_online_in_cat'=> new \Zend_Db_Expr('IF(e.entity_id,1,0)')]);
->columns(['is_online_in_cat_sub'=> new \Zend_Db_Expr('IF(e.entity_id,1,0)')]);

$this->getSelect()->columns('category_collection.is_online_in_cat');
$this->getSelect()->columns(['is_online_in_cat'=> new \Zend_Db_Expr('IF(category_collection.is_online_in_cat_sub,1,0)')]);
$this->getSelect()->joinLeft(['category_collection'=>$subSelect], 'main_table.entity_id = category_collection.p_entity_id');

//echo $this->productCollection->getSelect();
Expand Down