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

Cast is_in_stock to bool #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
26 changes: 13 additions & 13 deletions app/code/Ometria/Api/Controller/V1/Products.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,9 @@ protected function getItemsForJson()
// pass
}
}

$this->prepareChildParentRelationships($items);

$items = array_map(function($item){
return $this->serializeItem($item);
}, $items);
Expand Down Expand Up @@ -475,7 +475,7 @@ private function appendStock($productId, $item)
$stockItem = $this->stockRegistry->getStockItem($productId, $websiteId);

if (isset($stockItem['is_in_stock'])) {
$item['is_in_stock'] = $stockItem['is_in_stock'];
$item['is_in_stock'] = (bool) $stockItem['is_in_stock'];
}

if (isset($stockItem['qty'])) {
Expand Down Expand Up @@ -549,7 +549,7 @@ protected function getConfigurableProductParentChildIds(array $childIds)
$childToParentIds = [];

$connection = $this->resourceConnection->getConnection();

$select = $connection->select()
->from(
$this->resourceConnection->getTableName('catalog_product_super_link'),
Expand All @@ -559,9 +559,9 @@ protected function getConfigurableProductParentChildIds(array $childIds)
'product_id IN (?)',
$childIds
)
// order by the oldest links first so the iterator will end with the most recent link
// order by the oldest links first so the iterator will end with the most recent link
->order('link_id ASC');

$result = $connection->fetchAll($select);
foreach ($result as $_row) {
$childToParentIds[$_row['product_id']] = $_row['parent_id'];
Expand All @@ -573,7 +573,7 @@ protected function getConfigurableProductParentChildIds(array $childIds)
/**
* Bulk version of the native method to retrieve relationships one by one.
* @see \Magento\Bundle\Model\ResourceModel\Selection::getParentIdsByChild
*
*
* @param array $childIds
* @return array
*/
Expand All @@ -582,7 +582,7 @@ protected function getBundleProductParentChildIds(array $childIds)
$childToParentIds = [];

$connection = $this->resourceConnection->getConnection();

$select = $connection->select()
->from(
$this->resourceConnection->getTableName('catalog_product_bundle_selection'),
Expand All @@ -592,7 +592,7 @@ protected function getBundleProductParentChildIds(array $childIds)
'product_id IN (?)',
$childIds
)
// order by the oldest selections first so the iterator will end with the most recent link
// order by the oldest selections first so the iterator will end with the most recent link
->order('selection_id ASC');

$result = $connection->fetchAll($select);
Expand All @@ -606,7 +606,7 @@ protected function getBundleProductParentChildIds(array $childIds)
/**
* Bulk version of the native method to retrieve relationships one by one.
* @see \Magento\GroupedProduct\Model\ResourceModel\Product\Link::getParentIdsByChild
*
*
* @param array $childIds
* @return array
*/
Expand All @@ -615,7 +615,7 @@ protected function getGroupedProductParentChildIds(array $childIds)
$childToParentIds = [];

$connection = $this->resourceConnection->getConnection();

$select = $connection->select()
->from(
$this->resourceConnection->getTableName('catalog_product_link'),
Expand All @@ -629,7 +629,7 @@ protected function getGroupedProductParentChildIds(array $childIds)
'link_type_id = ?',
\Magento\GroupedProduct\Model\ResourceModel\Product\Link::LINK_TYPE_GROUPED
)
// order by the oldest links first so the iterator will end with the most recent link
// order by the oldest links first so the iterator will end with the most recent link
->order('link_id ASC');

$result = $connection->fetchAll($select);
Expand All @@ -647,7 +647,7 @@ protected function getGroupedProductParentChildIds(array $childIds)
protected function getVariantParentId($item)
{
$productId = $this->getArrayKey($item, 'id');

// if the product can be viewed individually, it should not be treated as a variant
$visibleInSiteVisibilities = [
\Magento\Catalog\Model\Product\Visibility::VISIBILITY_IN_CATALOG,
Expand Down