Set originalLineItem

@author Tom Haskins-Vaughan <tom@harvestcloud.com>
@since  2013-10-28

@param  \HarvestCloud\CoreBundle\Entity\OrderLineItem $originalLineItem

@return ProductSubscription
767216
public function setOriginalLineItem(\HarvestCloud\CoreBundle\Entity\OrderLineItem $originalLineItem = null)
    {
        $this->originalLineItem = $originalLineItem;

        return $this;
    }
1264634
public function setItem(Item $item)
    {
        if ($this->item !== $item) {
            $this->item = $item->setType($this);
        }

        return $this;
    }
751593
protected function setItemByProductData($productData, ApiItemInterface $item, $locale)
    {
        $productId = $this->getProductId($productData);

        /** @var Product $product */
        $product = $this->productRepository->find($productId);
        if (!$product) {
            throw new ProductNotFoundException(self::$productEntityName, $productId);
        }
        $item->setProduct($product);
        $translation = $product->getTranslation($locale);

        // when the product is not available in the current language choose the first translation you find
        // FIXME: should be changed when products have a language fallback
        // https://github.com/massiveart/POOL-ALPIN/issues/611
        if (is_null($translation)) {
            if (count($product->getTranslations()) > 0) {
                $translation = $product->getTranslations()[0];
            } else {
                throw new ProductException('Product ' . $product->getId() . ' has no translations!');
            }
        }

        $this->setItemSupplier($item, $product);

        $item->setName($translation->getName());
        $item->setDescription($translation->getLongDescription());
        $item->setNumber($product->getNumber());

        // set order unit
        if ($product->getOrderUnit()) {
            $item->setQuantityUnit($product->getOrderUnit()->getTranslation($locale)->getName());
        }

        // TODO: get tax from product https://github.com/massiveart/POOL-ALPIN/issues/1224
        $item->setTax(0);

        return $product;
    }
1137458
public function setItems($items)
    {
        $orderItems = [];
        foreach ($items as $item) {
            if (is_array($item)) {
                $orderItems[] = new Item($item);
            } elseif (! ($item instanceof Item)) {
                throw new \InvalidArgumentException('Item should be an instance of ' . Item::class);
            }
        }

        return parent::setItems($orderItems);
    }
613822
public function changeLines($originalLine, array $newLines)
    {
        $this->buffer->replace($this->createSingleLineRange($originalLine), $newLines);
    }
1309296
protected function _createItem( MShop_Price_Item_Interface $price, MShop_Locale_Item_Interface $locale,
		array $values = array(), array $products = array(), array $addresses = array(),
		array $services = array(), array $coupons = array() )
	{
		return new MShop_Order_Item_Base_Default( $price, $locale,
			$values, $products, $addresses, $services, $coupons );
	}
657295
public function setParent(\Amulen\PageBundle\Entity\MenuItem $parent = null)
    {
        $this->parent = $parent;

        return $this;
    }
58148
function copy( $collectionItemID )
    {
        $item = clone $this;
        $item->setAttribute( 'item_id', $collectionItemID );
        $item->store();
        return $item;
    }
671892
public function create()
    {
        $instance = self::createReturnLineItem($this);
        $this->setId($instance->getId());
        return $instance;
    }
594943
public function add($lineItem): void
    {
        $this->validateType($lineItem);

        $exists = $this->get($lineItem->getKey());

        if ($exists && $exists->getType() !== $lineItem->getType()) {
            throw new MixedLineItemTypeException($lineItem->getKey(), $exists->getType());
        }

        if ($exists) {
            $exists->setQuantity($lineItem->getQuantity() + $exists->getQuantity());

            return;
        }

        $this->elements[$this->getKey($lineItem)] = $lineItem;
    }
1117138
public function setMenuItem(MenuItemInterface $menuItem)
    {
        $menuItem->setPage($this);
        $this->menuItem = $menuItem;

        return $this;
    }
155011
public function product($orderLineHandle, $product)
    {
        $products = new Product($this->client_raw);
        $productHandle = $products->getHandle($product);

        $this->client
            ->OrderLine_SetProduct(
                array(
                    'orderLineHandle' => $orderLineHandle,
                    'valueHandle' => $productHandle
                )
            );

        return true;
    }
542225
private function isRealPromotionItem(LineItem $lineItem): bool
    {
        if ($lineItem->getType() !== self::LINE_ITEM_TYPE) {
            return false;
        }

        // its a correct line item type, so it can either be
        // a placeholder or a real one.
        return !$this->isPromotionPlaceholder($lineItem);
    }
1212513
public function fromApacheSolrDocument(Document $originalDocument)
    {

        $searchResultClassName = $this->getResultClassName();
        $result = GeneralUtility::makeInstance($searchResultClassName, /** @scrutinizer ignore-type */ $originalDocument->getFields() ?? []);

        if (!$result instanceof SearchResult) {
            throw new \InvalidArgumentException('Could not create result object with class: ' . (string)$searchResultClassName, 1470037679);
        }

        return $result;
    }
802232
public function assignSellerWindowToLineAction(OrderLineItem $orderLineItem, $window_id)
    {
        $em = $this->get('doctrine')->getManager();

        $window = $em->getRepository('HarvestCloudCoreBundle:SellerWindow')
            ->find((int) $window_id)
        ;

        $orderLineItem->setSellerWindow($window);

        $em->persist($orderLineItem);
        $em->persist($orderLineItem->getOrder());
        $em->flush();

        return $this->redirect($this->generateUrl('Profile_product_show', array(
            'product_slug' => $orderLineItem->getProduct()->getSlug(),
            'slug'         => $orderLineItem->getProduct()->getSeller()->getSlug(),
        )));
    }
1140434
public function getLineItemForProduct(Product $product)
    {
        foreach ($this->getLineItems() as $lineItem)
        {
            if ($lineItem->getProduct()->getId() == $product->getId())
            {
                return $lineItem;
            }
        }

        return $this->createLineItemForProduct($product);
    }
110715
public function setOrder(\Amulen\ShopBundle\Entity\ProductOrder $order = null)
    {
        $this->order = $order;

        return $this;
    }