Returns the stock items for the given product codes

@param \Aimeos\MShop\Context\Item\Iface $context Context item object
@param array $prodCodes List of product codes
@param string $stockType Stock type code
197222
protected function getStockItems( \Aimeos\MShop\Context\Item\Iface $context, array $prodCodes, $stockType )
	{
		$stockManager = \Aimeos\MShop::create( $context, 'stock' );

		$search = $stockManager->createSearch( true );
		$expr = array(
			$search->compare( '==', 'stock.productcode', $prodCodes ),
			$search->compare( '==', 'stock.type', $stockType ),
			$search->combine( '||', array(
				$search->compare( '==', 'stock.stocklevel', null ),
				$search->compare( '>', 'stock.stocklevel', 0 ),
			)),
			$search->getConditions(),
		);
		$search->setConditions( $search->combine( '&&', $expr ) );
		$search->setSlice( 0, 100000 ); // performance speedup

		return $stockManager->searchItems( $search );
	}
362058
public function updateStock(
        PurchasableInterface $purchasable,
        $stockToDecrease
    ) {
        $namespace = $this->getPurchasableNamespace();
        if (!$purchasable instanceof $namespace) {
            return false;
        }

        /**
         * @var $purchasable PackInterface
         */
        $stockType = $purchasable->getStockType();
        if ($stockType === ElcodiProductStock::INHERIT_STOCK) {
            return $this->updateStockOfPurchasablesByLoadedStockUpdaters(
                $purchasable->getPurchasables(),
                $stockToDecrease
            );
        }

        $decreasedStock = $this->updateSimplePurchasableStock(
            $purchasable,
            $stockToDecrease
        );

        if ($decreasedStock) {
            $this
                ->packObjectManager
                ->flush($purchasable);
        }

        return $decreasedStock;
    }
1023384
public static function get( \Aimeos\MW\Config\Iface $config )
	{
		if( self::$context === null )
		{
			// TYPO3 specifc context with password hasher
			$context = new \Aimeos\MShop\Context\Item\Typo3();
			$context->setConfig( $config );

			self::addDataBaseManager( $context );
			self::addFilesystemManager( $context );
			self::addMessageQueueManager( $context );
			self::addLogger( $context );
			self::addCache( $context );
			self::addMailer( $context);
			self::addProcess( $context );
			self::addSession( $context );
			self::addHasher( $context);
			self::addUser( $context);
			self::addGroups( $context);

			self::$context = $context;
		}

		// Use local TS configuration from plugins
		self::$context->setConfig( $config );

		return self::$context;
	}
1060743
protected function getStockItems( array $productCodes )
	{
		$context = $this->getContext();

		/** client/html/catalog/stock/sort
		 * Sortation key if stock levels for different types exist
		 *
		 * Products can be shipped from several warehouses with a different
		 * stock level for each one. The stock levels for each warehouse will
		 * be shown in the product detail page. To get a consistent sortation
		 * of this list, the configured key will be used by the stock manager.
		 *
		 * Possible keys for sorting are ("-stock.type" for descending order):
		 * * stock.productcode
		 * * stock.stocklevel
		 * * stock.type
		 * * stock.dateback
		 *
		 * @param array List of key/value pairs for sorting
		 * @since 2017.01
		 * @category Developer
		 * @see client/html/catalog/stock/level/low
		 */
		$sort = $context->getConfig()->get( 'client/html/catalog/stock/sort', 'stock.type' );
		$type = $context->getLocale()->getSite()->getConfigValue( 'stocktype' );

		return \Aimeos\Controller\Frontend::create( $context, 'stock' )
			->code( $productCodes )->type( $type )->sort( $sort )
			->slice( 0, count( $productCodes ) )
			->search();
	}
463328
public function getStockData($minProductId, $maxProductId)
    {
        $this->stockData = [];
        $stockQuery = $this->_resource->getConnection()->select()
            ->from($this->getTable('cataloginventory_stock_item'), ['is_in_stock', 'qty', 'product_id'])
            ->where('product_id >= ?', $minProductId)
            ->where('product_id <= ?', $maxProductId)
            ->where('stock_id = ?', 1);

        $this->iterator->walk(
            (string)$stockQuery,
            [[$this, 'handleStockItem']],
            [],
            $this->_resource->getConnection()
        );

        return $this->stockData;
    }
763108
private function getStockItemId($prodId, $stockId)
    {
        $query = $this->qbGetStockItem->build();
        $conn = $query->getConnection();
        $bind = [
            OwnQbGetStockItem::BND_PROD_ID => $prodId,
            OwnQbGetStockItem::BND_STOCK_ID => $stockId
        ];
        $result = $conn->fetchOne($query, $bind);
        return $result;
    }
285132
public function getCombinations(string $productId, Context $context)
    {
        return new JsonResponse(
            $this->combinationLoader->load($productId, $context)
        );
    }
1238294
protected function addLogger( \Aimeos\MShop\Context\Item\Iface $context )
	{
		$logger = \Aimeos\MAdmin::create( $context, 'log' );

		return $context->setLogger( $logger );
	}
593947
protected function toArray( \Aimeos\MShop\Common\Item\Type\Iface $item, $copy = false )
	{
		$data = $item->toArray( true );

		if( $copy === true )
		{
			$data['price.lists.type.code'] = $data['price.lists.type.code'] . '_copy';
			$data['price.lists.type.id'] = '';
		}

		return $data;
	}
420360
protected function getStockItems( array $codes, array $types )
	{
		$map = [];
		$manager = \Aimeos\MShop::create( $this->getContext(), 'stock' );

		$search = $manager->createSearch()->setSlice( 0, 10000 );
		$search->setConditions( $search->combine( '&&', [
			$search->compare( '==', 'stock.productcode', $codes ),
			$search->compare( '==', 'stock.type', $types )
		] ) );

		foreach( $manager->searchItems( $search ) as $item ) {
			$map[$item->getProductCode()][$item->getType()] = $item;
		}

		return $map;
	}
423787
protected static function addMessageQueueManager( \Aimeos\MShop\Context\Item\Iface $context )
	{
		if( isset( $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_context_mqueue'] )
			&& is_callable( ( $fcn = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_context_mqueue'] ) )
		) {
			return $fcn( $context );
		}

		return $context->setMessageQueueManager( new \Aimeos\MW\MQueue\Manager\Standard( $context->getConfig() ) );
	}
1250021
protected function fromArray( \Aimeos\MShop\Product\Item\Iface $item, array $data )
	{
		$manager = \Aimeos\MShop::create( $this->getContext(), 'product/property' );
		$typeManager = \Aimeos\MShop::create( $this->getContext(), 'product/property/type' );

		foreach( $data as $type => $value )
		{
			$propItems = $item->getPropertyItems( $type, false );

			if( ( $value = trim( $value ) ) != '' )
			{
				if( ( $propItem = reset( $propItems ) ) === false ) {
					$propItem = $manager->createItem()->setType( $type );
				}

				$propItem->setLanguageId( null );
				$propItem->setValue( $value );

				$item->addPropertyItem( $propItem );
			}
			else
			{
				$item->deletePropertyItems( $propItems );
			}
		}
	}
777527
protected static function addMailer( \Aimeos\MShop\Context\Item\Iface $context )
	{
		if( isset( $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_context_mailer'] )
			&& is_callable( ( $fcn = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_context_mailer'] ) )
		) {
			return $fcn( $context );
		}

		return $context->setMail( new \Aimeos\MW\Mail\Typo3( function() {
			return GeneralUtility::makeInstance( \TYPO3\CMS\Core\Mail\MailMessage::class );
		} ) );
	}
569263
public function getList($prodict_id)
    {
        $result = null;
        $this->hook->attach('product.field.list.before', $prodict_id, $result, $this);

        if (isset($result)) {
            return $result;
        }

        $sql = 'SELECT * FROM product_field WHERE product_id=?';
        $fields = $this->db->fetchAll($sql, array($prodict_id));

        $result = array();
        foreach ($fields as $field) {
            $result[$field['type']][$field['field_id']][] = $field['field_value_id'];
        }

        $this->hook->attach('product.field.list.after', $prodict_id, $result, $this);
        return $result;
    }
1236335
protected function importStocks( \Aimeos\MW\Container\Content\Iface $content, $maxcnt )
	{
		$total = 0;
		$manager = \Aimeos\MShop::create( $this->getContext(), 'stock' );

		do
		{
			$count = 0;
			$codes = $data = $items = $types = [];

			while( $content->valid() && $count < $maxcnt )
			{
				$row = $content->current();
				$content->next();

				if( $row[0] == '' ) {
					continue;
				}

				$type = $this->getValue( $row, 2, 'default' );
				$types[$type] = null;
				$codes[] = $row[0];
				$row[2] = $type;
				$data[] = $row;

				$count++;
			}

			if( $count === 0 ) {
				break;
			}

			$items = [];
			$map = $this->getStockItems( $codes, array_keys( $types ) );

			foreach( $data as $entry )
			{
				$code = $entry[0];
				$type = $entry[2];

				if( isset( $map[$code][$type] ) ) {
					$item = $map[$code][$type];
				} else {
					$item = $manager->createItem();
				}

				$items[] = $item->setProductCode( $code )->setType( $type )
					->setStocklevel( $this->getValue( $entry, 1 ) )
					->setDateBack( $this->getValue( $entry, 3 ) );

				unset( $map[$code][$type] );
			}

			$manager->saveItems( $items );
			unset( $items );

			$total += $count;
		}
		while( $count > 0 );

		return $total;
	}
1325179
public function process( \Aimeos\MShop\Coupon\Item\Code\Iface $item, array $data )
	{
		return $data;
	}
1234487
public function getPvByProductAndStock($productId, $stockId)
    {
        /* aliases and tables */
        $asStockItem = 'csi';
        $asPv = 'ppsi';
        $tblStockItem = [$asStockItem => $this->resource->getTableName(Cfg::ENTITY_MAGE_CATALOGINVENTORY_STOCK_ITEM)];
        $tblPv = [$asPv => $this->resource->getTableName(Entity::ENTITY_NAME)];
        /* SELECT FROM cataloginventory_stock_item */
        $query = $this->conn->select();
        $cols = [];
        $query->from($tblStockItem, $cols);
        /* LEFT JOIN prxgt_pv_stock_item */
        $on = $asPv . '.' . Entity::A_ITEM_REF . '=' . $asStockItem . '.' . Cfg::E_CATINV_STOCK_ITEM_A_ITEM_ID;
        $cols = [Entity::A_PV];
        $query->joinLeft($tblPv, $on, $cols);
        /* WHERE */
        $where = $asStockItem . '.' . Cfg::E_CATINV_STOCK_ITEM_A_PROD_ID . '=' . (int)$productId;
        $where .= ' AND ' . $asStockItem . '.' . Cfg::E_CATINV_STOCK_ITEM_A_STOCK_ID . '=' . (int)$stockId;
        $query->where($where);
        /* fetch data */
        $result = $this->conn->fetchOne($query);
        return $result;
    }