From 880505b4ad16dcded8a7b699fb08a2456c46b06f Mon Sep 17 00:00:00 2001 From: Al James Date: Wed, 25 Mar 2020 16:33:03 +0000 Subject: [PATCH] Cast is_in_stock to bool --- .../Ometria/Api/Controller/V1/Products.php | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/app/code/Ometria/Api/Controller/V1/Products.php b/app/code/Ometria/Api/Controller/V1/Products.php index 74c4976..0b37b53 100755 --- a/app/code/Ometria/Api/Controller/V1/Products.php +++ b/app/code/Ometria/Api/Controller/V1/Products.php @@ -254,9 +254,9 @@ protected function getItemsForJson() // pass } } - + $this->prepareChildParentRelationships($items); - + $items = array_map(function($item){ return $this->serializeItem($item); }, $items); @@ -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'])) { @@ -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'), @@ -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']; @@ -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 */ @@ -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'), @@ -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); @@ -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 */ @@ -615,7 +615,7 @@ protected function getGroupedProductParentChildIds(array $childIds) $childToParentIds = []; $connection = $this->resourceConnection->getConnection(); - + $select = $connection->select() ->from( $this->resourceConnection->getTableName('catalog_product_link'), @@ -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); @@ -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,