Adapter/PlentymarketsAdapter/ResponseParser/Product/Stock/StockResponseParser.php
private function getStock($variation)
    {
        $arrayStocks = [];
        $itemWarehouse = (int) $this->configService->get('item_warehouse', 0);

        static $warehouses;

        if (null === $warehouses) {
            $warehouses = $this->client->request('GET', 'stockmanagement/warehouses');

            $warehouses = array_filter($warehouses, function (array $warehouse) {
                return $warehouse['typeId'] === self::SALES_WAREHOUSE;
            });

            $warehouses = array_column($warehouses, 'id');
        }

        foreach ($variation['stock'] as $stock) {
            if (!in_array($stock['warehouseId'], $warehouses, true)) {
                continue;
            }

            if ($itemWarehouse !== 0 && $stock['warehouseId'] !== $itemWarehouse) {
                continue;
            }

            if ($stock['variationId'] !== $variation['id']) {
                continue;
            }

            $arrayStocks[] = $stock['netStock'];
        }

        return (float) array_sum($arrayStocks);
    }
private function getStock($variation)
    {
        $arrayStocks = [];
        $itemWarehouse = (int) $this->configService->get('item_warehouse', 0);

        static $warehouses;

        if (null === $warehouses) {
            $warehouses = $this->client->request('GET', 'stockmanagement/warehouses');

            $warehouses = array_filter($warehouses, function (array $warehouse) {
                return $warehouse['typeId'] === self::SALES_WAREHOUSE;
            });

            $warehouses = array_column($warehouses, 'id');
        }

        foreach ($variation['stock'] as $stock) {
            if (!in_array($stock['warehouseId'], $warehouses, true)) {
                continue;
            }

            if ($itemWarehouse !== 0 && $stock['warehouseId'] !== $itemWarehouse) {
                continue;
            }

            if ($stock['variationId'] !== $variation['id']) {
                continue;
            }

            $arrayStocks[] = $stock['netStock'];
        }

        return (float) array_sum($arrayStocks);
    }
private function getStock ( $ variation ) { $ arrayStocks = [ ] ; $ itemWarehouse = ( int ) $ this -> configService -> get ( 'item_warehouse' , 0 ) ; static $ warehouses ; if ( null === $ warehouses ) { $ warehouses = $ this -> client -> request ( 'GET' , 'stockmanagement/warehouses' ) ; $ warehouses = array_filter ( $ warehouses , function ( array $ warehouse ) { return $ warehouse [ 'typeId' ] === self :: SALES_WAREHOUSE ; } ) ; $ warehouses = array_column ( $ warehouses , 'id' ) ; } foreach ( $ variation [ 'stock' ] as $ stock ) { if ( ! in_array ( $ stock [ 'warehouseId' ] , $ warehouses , true ) ) { continue ; } if ( $ itemWarehouse !== 0 && $ stock [ 'warehouseId' ] !== $ itemWarehouse ) { continue ; } if ( $ stock [ 'variationId' ] !== $ variation [ 'id' ] ) { continue ; } $ arrayStocks [ ] = $ stock [ 'netStock' ] ; } return ( float ) array_sum ( $ arrayStocks ) ; }
@param array $variation

@return float
@param array $variation