Insert item

@param array $product

@return bool
431608
public function item(Array $product) : Bool
    {
        if( ! isset($product['quantity']) )
        {
            $product['quantity'] = 1;
        }

        array_push(Properties::$items, $product);

        $this->driver->insert($this->key, Properties::$items);

        Properties::$items = $this->driver->select($this->key);

        return true;
    }
545098
public static function insertInside(array $array, $items, $where)
    {
        foreach ($items as $k => $v) {
            unset($array[$k]);
        }
        $before = self::prepareWhere($array, isset($where['before']) ? $where['before'] : null);
        $after  = self::prepareWhere($array, isset($where['after']) ? $where['after'] : null);
        $new    = [];
        $found  = false;
        /// TODO think of realizing it better
        foreach ($array as $k => $v) {
            if (!$found && $k === $before) {
                foreach ($items as $i => $c) {
                    $new[$i] = $c;
                }
                $found = true;
            }
            $new[$k] = $v;
            if (!$found && $k === $after) {
                foreach ($items as $i => $c) {
                    $new[$i] = $c;
                }
                $found = true;
            }
        }
        if (!$found) {
            foreach ($items as $i => $c) {
                $new[$i] = $c;
            }
        }

        return $new;
    }
460933
public function addProductToHuskyItemTable($product)
    {
        $itemTableFormElement = $this->getSession()->getPage()->find('css', '#item-table-form');

        if (null === $itemTableFormElement) {
            throw new ElementNotFoundException($this->getSession(), '#item-table-form');
        }

        // Press add button in table.
        $addButtonElement = $itemTableFormElement->find('css', '.toolbar-item.add-row');

        if (null === $addButtonElement) {
            throw new ElementNotFoundException($this->getSession(), '#item-table-form .toolbar-item.add-row');
        }

        $addButtonElement->click();

        // Now wait for the new table row.
        $this->waitForSelector('#item-table-form .item-table-row.new');

        // Fill in auto complete product.
        $this->iSelectFromTheHuskyAutoComplete($product, '.item-table-row.new .product-search');

        // Wait until loading is finished.
        $this->spin(function (RawMinkContext $context) {
            $spinnerElement = $context->getSession()->getPage()->find(
                'css',
                '.item-table-row.new .product-search .spinner'
            );

            if ($spinnerElement && $spinnerElement->isVisible()) {
                return false;
            }

            return true;
        });
    }
1207243
public function insert($arr,$filter=false) {
        if($filter) $arr = array_filter($arr,$filter);
        return $this->driver->insert($arr);
    }
983391
public function post(array $products) {
    $storeId = '';
    $requestHeaders = $this->currentRequest->headers;
    if ($requestHeaders->has('X-ACM-UUID')) {
      $storeId = $requestHeaders->get('X-ACM-UUID');
    }

    \Drupal::logger('acm_sku')->info("Updating products for acm_uuid " . $storeId . ".");

    // To avoid even E_RECOVERABLE_ERROR, we set our custom error handler.
    set_error_handler([$this, 'errorHandler']);

    $response = $this->productManager->synchronizeProducts($products, $storeId);
    return (new ModifiedResourceResponse($response));
  }
71812
public static function attach( $product, $modules ) {

		if ( ! isset( self::$modules_attached[ $product->get_slug() ] ) ) {
			self::$modules_attached[ $product->get_slug() ] = [];
		}

		foreach ( $modules as $module ) {
			$class = 'ThemeisleSDK\\Modules\\' . ucwords( $module, '_' );
			/**
			 * Module object.
			 *
			 * @var Abstract_Module $module_object Module instance.
			 */
			$module_object = new  $class( $product );

			if ( ! $module_object->can_load( $product ) ) {
				continue;
			}
			self::$modules_attached[ $product->get_slug() ][ $module ] = $module_object->load( $product );
		}
	}
1163712
public function insert($table, array $map = []): Query\InsertQuery
    {
        $query = $this->engine->makeInsert()->into($table);
        if (empty($map) === false) {
            $query = $query->map($map);
        }
        return $query;
    }
110412
public function insert($params)
    {
        if (is_array($params)) {
            $count_rows = count($params['columns']);
            $increment = 1;
            foreach ($params['columns'] as $keys => $value) {
                for ($i = 1; $i <= $count_rows; $i++) {
                    $data[$keys] = $value;
                }
            }
            foreach ($data as $keys => $values) {
                if ($increment == $count_rows) {
                    $columns[] = "{$keys} = '{$values}'";
                } else {
                    $columns[] = "{$keys} = '{$values}'";
                }
                $increment++;
            }
            $columns = implode(' , ', $columns);
            $query = "INSERT INTO `{$params['table']}`SET {$columns}";
            if (isset($params['debug']) and strtolower($params['debug']) === 'on') {
                var_dump($query);
            }

            return $query;
        } else {
            return false;
        }
    }
159909
public function insert(array $quill)
    {
        $insert = $quill['insert'];

        /**
         * @var Delta
         */
        $delta = new $this->class_delta_insert($insert, (array_key_exists('attributes', $quill) ? $quill['attributes'] : []));

        if (preg_match("/[\n]{2,}/", $insert) !== 0) {
            $delta->setClose();
        } else {
            if (preg_match("/[\n]{1}/", $insert) !== 0) {
                $delta->setNewLine();
            }
        }

        $this->deltas[] = $delta;
    }
1242278
public function insert($key, array $data)
    {
        if (key_exists($key, $this->items)) {
            $this->items[$key] = $data;
        } else {
            $this->items[$key] = $data;
        }
        return $this;
    }
1202213
public function insert(array $data) {
		$data = $this->filterFields($data, $this->_allowed_insert_fields);
		$data['created_at'] = Factory::load('\datetime')->format('Y-m-d H:i:s');

		return $this->_db->insertSafe($this->_table, $data);
	}
1161241
public function insert(array $data)
    {
        if (false === $this->trigger('before_insert', $this)) {
            return false;
        }

        if($this->dateFormat && $this->updateTime && $this->createTime){
            $time = date('Y-m-d H:i:s', time());
            $data[$this->updateTime] = $time;
            $data[$this->createTime] = $time;
        } else {
            $time =  time();
            $data[$this->updateTime] =  $time;
            $data[$this->createTime] =  $time;
        }

        $response = $this->getQuery()->insert($data);

        if (false === $this->trigger('after_insert', $this)) {
            return false;
        }
        return $response;
    }
94349
public function create(Product $product)
    {
        $this->getEm()->persist($product);
        $this->getEm()->flush();

        return $product;
    }
439676
public function add(Product $product, int $quantity)
    {
        if (!$product->isAvailable()) {
            throw new ProductNotAvailableException($product);
        }

        if (!$product->price()->hasCurrency($this->currency)) {
            throw new InvalidCurrencyException($this->currency, $product->price()->currency());
        }

        if (array_key_exists((string) $product->sku(), $this->items)) {
            $quantity += $this->items[(string) $product->sku()]->quantity();
        }

        $this->items[(string) $product->sku()] = new CartItem($product->sku(), $quantity);
    }
25915
protected function attachFields(array &$product)
    {
        if (empty($product)) {
            return $product;
        }

        $product['field'] = $this->product_field->getList($product['product_id']);

        if (empty($product['field']['option'])) {
            return $product;
        }

        foreach ($product['field']['option'] as &$field_values) {
            $field_values = array_unique($field_values);
        }

        return $product;
    }
603295
protected function _createItem( array $entry )
	{
		$item = $this->_manager->createItem();

		foreach( $entry as $name => $value )
		{
			switch( $name )
			{
				case 'product.tag.id': $item->setId( $value ); break;
				case 'product.tag.label': $item->setLabel( $value ); break;
				case 'product.tag.typeid': $item->setTypeId( $value ); break;
				case 'product.tag.languageid':
					if( $value != '' ) {
						$item->setLanguageId( $value );
					}
					break;
			}
		}

		return $item;
	}
659826
protected function prepareProduct(array &$product)
    {
        $options = array(
            'store_id' => $product['store_id'],
            'product_id' => $product['product_id']
        );

        $product['related'] = $this->product->getRelated($options);
        $product['price'] = $this->price->decimal($product['price'], $product['currency']);

        $this->setSkuCombinationProduct($product);
        $this->setItemAlias($product, 'product', $this->alias);
        $this->setItemImages($product, 'product', $this->image);
        $this->setItemTranslation($product, 'product', $this->translation_entity);

        if (!empty($product['images'])) {
            foreach ($product['images'] as &$file) {
                $this->setItemTranslation($file, 'file', $this->translation_entity);
            }
        }
    }