Creates a new price item or updates an existing one or a list thereof.

@param stdClass $params Associative array containing the text properties
767209
public function saveItems( stdClass $params )
	{
		$this->_checkParams( $params, array( 'site', 'items' ) );
		$this->_setLocale( $params->site );

		$ids = array();
		$items = ( !is_array( $params->items ) ? array( $params->items ) : $params->items );

		foreach( $items as $entry )
		{
			$item = $this->_createItem( (array) $entry );
			$this->_manager->saveItem( $item );
			$ids[] = $item->getId();
		}

		$this->_clearCache( $ids );

		$search = $this->_manager->createSearch();
		$search->setConditions( $search->compare( '==', 'price.id', $ids ) );
		$search->setSlice( 0, count( $ids ) );
		$items = $this->_toArray( $this->_manager->searchItems( $search ) );

		return array(
			'items' => ( !is_array( $params->items ) ? reset( $items ) : $items ),
			'success' => true,
		);
	}
1176611
public function prepareParms($params)
    {
        if (is_array($params)) {
            foreach ($params as $key => $value) {
                array_push($this->setParams, $value);
            }
        } else {
            array_push($this->setParams, $params);
        }
    }
708907
public function setParams($params)
    {
        foreach ($params as $name => $value) {
            $this->setParam($name, $value);
        }
        return $this;
    }
329951
public function createJob( \stdClass $params )
	{
		$this->checkParams( $params, array( 'site', 'items' ) );
		$this->setLocale( $params->site );

		$context = $this->getContext();

		$items = (array) $params->items;
		$lang = ( property_exists( $params, 'lang' ) ) ? (array) $params->lang : [];

		$languages = ( !empty( $lang ) ) ? implode( $lang, '-' ) : 'all';

		$result = (object) array(
			'site' => $params->site,
			'items' => array(
				(object) array(
					'job.label' => 'Product text export: ' . $languages,
					'job.method' => 'Product_Export_Text.exportFile',
					'job.parameter' => array(
						'site' => $params->site,
						'items' => $items,
						'lang' => $params->lang,
					),
					'job.status' => 1,
				),
			),
		);

		$jobController = \Aimeos\Controller\ExtJS\Admin\Job\Factory::createController( $context );
		$jobController->saveItems( $result );

		return array(
			'items' => $items,
			'success' => true,
		);
	}
330618
public function searchItems( \stdClass $params )
	{
		$this->checkParams( $params, array( 'site' ) );
		$this->setLocale( $params->site );

		$total = 0;
		$search = $this->initCriteria( $this->getManager()->createSearch(), $params );

		if( isset( $params->domain ) && isset( $params->parentid )
			&& ( !isset( $params->options->showall ) || $params->options->showall == false ) )
		{
			$listManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $params->domain . '/lists' );
			$criteria = $listManager->createSearch();

			$expr = [];
			$expr[] = $criteria->compare( '==', $params->domain . '.lists.parentid', $params->parentid );
			$expr[] = $criteria->compare( '==', $params->domain . '.lists.domain', 'price' );
			$criteria->setConditions( $criteria->combine( '&&', $expr ) );

			$result = $listManager->searchItems( $criteria );

			$ids = [];
			foreach( $result as $items ) {
				$ids[] = $items->getRefId();
			}

			$expr = [];
			$expr[] = $search->compare( '==', 'price.id', $ids );
			$expr[] = $search->getConditions();
			$search->setConditions( $search->combine( '&&', $expr ) );
		}

		$items = $this->getManager()->searchItems( $search, [], $total );

		return array(
			'items' => $this->toArray( $items ),
			'total' => $total,
			'success' => true,
		);
	}
328447
public function searchItems( stdClass $params )
	{
		$manager = $this->_getManager();

		$total = 0;
		$search = $manager->createSearch();

		/** controller/extjs/locale/language/default/showall
		 * Displays all available languages in lists instead of only the used ones
		 *
		 * By default, all available languages are shown in the lists displaying
		 * languages in the administration interface, e.g. in text or media panels.
		 * The content of these lists can be limited to the languages used by the
		 * locales created for a site. This can help editors to manage content
		 * faster.
		 *
		 * @param boolean True for all languages, false for only the ones used by existing locales
		 * @since 2014.03
		 * @category Developer
		 * @category User
		 */
		if( !$this->_getContext()->getConfig()->get( 'controller/extjs/locale/language/default/showall', true ) )
		{
			$localeManager = MShop_Locale_Manager_Factory::createManager( $this->_getContext() );

			$langids = array();
			foreach( $localeManager->searchItems( $localeManager->createSearch() ) as $item ) {
				$langids[] = $item->getLanguageId();
			}

			if( !empty( $langids ) ) {
				$search->setConditions( $search->compare( '==', 'locale.language.id', $langids ) );
			}
		}

		$search = $this->_initCriteria( $search, $params );

		$sort = $search->getSortations();
		$sort[] = $search->sort( '+', 'locale.language.label' );
		$search->setSortations( $sort );

		$items = $this->_getManager()->searchItems( $search, array(), $total );

		return array(
			'items' => $this->_toArray( $items ),
			'total' => $total,
			'success' => true,
		);
	}
1027782
public function moveItems( stdClass $params )
	{
		$this->_checkParams( $params, array( 'site', 'items', 'oldparentid', 'newparentid' ) );
		$this->_setLocale( $params->site );

		$manager = $this->_getManager();

		$ids = array();
		$refId = ( isset( $params->refid ) ? $params->refid : null );
		$items = ( !is_array( $params->items ) ? array( $params->items ) : $params->items );

		foreach( $items as $entry )
		{
			$manager->moveItem( $entry, $params->oldparentid, $params->newparentid, $refId );
			$ids[] = $entry->id;
		}

		$this->_clearCache( $ids );

		return array(
			'success' => true,
		);
	}
181260
public function insertItems( \stdClass $params )
	{
		$this->checkParams( $params, array( 'items' ) );

		$manager = $this->getManager();

		$refId = ( isset( $params->refid ) ? $params->refid : null );
		$parentId = ( ( isset( $params->parentid ) && $params->parentid !== 'root' ) ? $params->parentid : null );
		$items = ( !is_array( $params->items ) ? array( $params->items ) : $params->items );

		foreach( $items as $entry )
		{
			$item = $manager->createItem();
			$item->fromArray( (array) $this->transformValues( $entry ) );
			$manager->insertItem( $item, $parentId, $refId );

			$entry->{'locale.site.id'} = $item->getId();
		}

		return array(
			'items' => ( !is_array( $params->items ) ? reset( $items ) : $items ),
			'success' => true,
		);
	}
1085257
public function searchItems( stdClass $params )
	{
		$this->_checkParams( $params, array( 'site' ) );
		$this->_setLocale( $params->site );

		$total = 0;
		$search = $this->_initCriteria( $this->_getManager()->createSearch(), $params );
		$items = $this->_getManager()->searchItems( $search, array(), $total );

		return array(
			'items' => $this->_toArray( $items ),
			'total' => $total,
			'success' => true,
		);
	}
665889
private function buildParams(\stdClass $params, array $whiteList) {
        $isRoot = is_null($this->getAlias());
        $children = array();
        $fields = array();
        foreach($params as $subAlias => $value) {
            if(is_object($value) && get_class($value) == 'stdClass') {
                $children[] = new Search($value, $whiteList, ucfirst($subAlias));
            } else { //For current object
                if(!$isRoot || !in_array($subAlias, $whiteList)) {
                    $fields[$subAlias] = $value;
                }
            }
        }
        $this->setChildren($children);
        $this->setFields($fields);
    }
988166
public function insertItems( stdClass $params )
	{
		$this->_checkParams( $params, array( 'items' ) );

		$manager = $this->_getManager();

		$refId = ( isset( $params->refid ) ? $params->refid : null );
		$parentId = ( ( isset( $params->parentid ) && $params->parentid !== 'root' ) ? $params->parentid : null );
		$items = ( !is_array( $params->items ) ? array( $params->items ) : $params->items );

		foreach( $items as $entry )
		{
			$item = $this->_createItem( (array) $entry );
			$manager->insertItem( $item, $parentId, $refId );

			$entry->{'locale.site.id'} = $item->getId();
		}

		return array(
			'items' => ( !is_array( $params->items ) ? reset( $items ) : $items ),
			'success' => true,
		);
	}
12462
protected function createElement(array $params = [])
    {
        $root = $this->createRoot();
        foreach ($params as $param) {
            $this->addElement($param, $root);
        }

        return $root;
    }
948205
public function importFile( stdClass $params )
	{
		$this->_checkParams( $params, array( 'site', 'couponid', 'items' ) );
		$this->_setLocale( $params->site );

		/** controller/extjs/coupon/code/default/container/type
		 * Container file type storing all coupon code files to import
		 *
		 * All coupon code files or content objects must be put into one
		 * container file so editors don't have to upload one file for each
		 * coupon code file.
		 *
		 * The container file types that are supported by default are:
		 * * Zip
		 *
		 * Extensions implement other container types like spread sheets, XMLs or
		 * more advanced ways of handling the exported data.
		 *
		 * @param string Container file type
		 * @since 2014.09
		 * @category Developer
		 * @category User
		 * @see controller/extjs/coupon/code/default/container/format
		 */

		/** controller/extjs/coupon/code/default/container/format
		 * Format of the coupon code files to import
		 *
		 * The coupon codes are stored in one or more files or content
		 * objects. The format of that file or content object can be configured
		 * with this option but most formats are bound to a specific container
		 * type.
		 *
		 * The formats that are supported by default are:
		 * * CSV (requires container type "Zip")
		 *
		 * Extensions implement other container types like spread sheets, XMLs or
		 * more advanced ways of handling the exported data.
		 *
		 * @param string Content file type
		 * @since 2014.09
		 * @category Developer
		 * @category User
		 * @see controller/extjs/coupon/code/default/container/type
		 * @see controller/extjs/coupon/code/default/container/options
		 */

		/** controller/extjs/coupon/code/default/container/options
		 * Options changing the expected format of the coupon codes to import
		 *
		 * Each content format may support some configuration options to change
		 * the output for that content type.
		 *
		 * The options for the CSV content format are:
		 * * csv-separator, default ','
		 * * csv-enclosure, default '"'
		 * * csv-escape, default '"'
		 * * csv-lineend, default '\n'
		 *
		 * For format options provided by other container types implemented by
		 * extensions, please have a look into the extension documentation.
		 *
		 * @param array Associative list of options with the name as key and its value
		 * @since 2014.09
		 * @category Developer
		 * @category User
		 * @see controller/extjs/coupon/code/default/container/format
		 */

		$config = $this->_getContext()->getConfig();

		$type = $config->get( 'controller/extjs/coupon/code/default/container/type', 'Zip' );
		$format = $config->get( 'controller/extjs/coupon/code/default/container/format', 'CSV' );
		$options = $config->get( 'controller/extjs/coupon/code/default/container/options', array() );

		$items = ( !is_array( $params->items ) ? array( $params->items ) : $params->items );

		foreach( $items as $path )
		{
			$container = MW_Container_Factory::getContainer( $path, $type, $format, $options );

			foreach( $container as $content ) {
				$this->_importContent( $content, $params->couponid );
			}

			unlink( $path );
		}

		return array(
			'success' => true,
		);
	}
646830
public function setProtectedProperty(...$params)
    {
        if (is_string($params[0])) {
            list($className, $object, $name, $value) = $params;
        } elseif (is_object($params[0])) {
            list($object, $name, $value) = $params;
            $className = get_class($object);
        }

        /** @var string $className */
        /** @var object $object */
        /** @var string $name */
        /** @var mixed $value */

        $this->checkOnObject($object);
        $this->checkOnMemberName($name);

        $reflector = $this->getReflectionProperty($className, $name);
        $isProtected = $reflector->isProtected() || $reflector->isPrivate();

        if ($isProtected) {
            $reflector->setAccessible(true);
        }
        $reflector->setValue($object, $value);
        if ($isProtected) {
            $reflector->setAccessible(false);
        }
    }
1168313
public function searchItems( \stdClass $params )
	{
		$manager = $this->getManager();

		$total = 0;
		$search = $manager->createSearch();

		if( isset( $params->options->showall ) && $params->options->showall == false )
		{
			$localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager( $this->getContext() );

			$langids = [];
			foreach( $localeManager->searchItems( $localeManager->createSearch() ) as $item ) {
				$langids[] = $item->getLanguageId();
			}

			if( !empty( $langids ) ) {
				$search->setConditions( $search->compare( '==', 'locale.language.id', $langids ) );
			}
		}

		$search = $this->initCriteria( $search, $params );

		$sort = $search->getSortations();
		$sort[] = $search->sort( '+', 'locale.language.label' );
		$search->setSortations( $sort );

		$items = $this->getManager()->searchItems( $search, [], $total );

		return array(
			'items' => $this->toArray( $items ),
			'total' => $total,
			'success' => true,
		);
	}
1368184
public function create($name, $params = []) {
		if($this->isClassName($name)) {
			$className = $name;
		} else {
			$className = $this->genClassName($name);
		}
		$result = [];
		$params = ArrayHelper::toArray($params);
		if(!empty($params) && ArrayHelper::isIndexed($params)) {
			foreach($params as $item) {
				$result[] = $this->createClass($className, $item);
			}
		} else {
			$result = $this->createClass($className, $params);
		}
		return $result;
	}
798571
public function setParams(array $params = array())
    {
        foreach ($params as $key => $value) {
            if (null != $value) {
                $this->$key = $value;
            }
        }

        return $this;
    }