@name            removeProductsFromLocale ()

@since           1.2.3
@version         1.5.3
@author          Can Berkol

@param           array $products
@param           mixed $locale

@return          \BiberLtd\Bundle\CoreBundle\Responses\ModelResponse
188098
public function removeProductsFromLocale($products, $locale)
	{
		$timeStamp = time();
		$mlsModel = $this->kernel->getContainer()->get('multilanguagesupport.model');
		$response = $mlsModel->getLanguage($locale);
		if ($response->error->exist) {
			return $response;
		}
		$locale = $response->result->set;
		$toRemove = array();
		$count = 0;
		foreach ($products as $product) {
			$response = $this->getProduct($product);
			if ($response->error->exist) {
				continue;
			}
			$toRemove[] = $response->result->set->getId();
			$count++;
		}
		if ($count > 0) {
			$ids = implode(',', $toRemove);
			$table = $this->entity['apl']['name'] . ' ' . $this->entity['apl']['alias'];
			$qStr = 'DELETE FROM ' . $table
				. ' WHERE ' . $this->entity['apl']['alias'] . '.locale = ' . $locale->getId()
				. ' AND ' . $this->entity['apl']['alias'] . '.category IN(' . $ids . ')';

			$query = $this->em->createQuery($qStr);
			$query->getResult();
			return new ModelResponse(null, 0, 0, null, false, 'S:D:001', 'Selected entries have been successfully removed from database.', $timeStamp, time());
		}
		return new ModelResponse(null, 0, 0, null, true, 'E:E:001', 'Unable to delete all or some of the selected entries.', $timeStamp, time());
	}
578017
public function removeTranslation($locale = null) {
        $translation = $this->translate($locale);

        if(! is_null($translation))
            $translation->delete();

        return $this;
    }
1066229
public function removeProductorder(\Flowcode\ShopBundle\Entity\ProductOrder $productorders)
    {
        $this->productorders->removeElement($productorders);
    }
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;
    }
1299449
protected function deleteProducts( \Aimeos\MW\View\Iface $view )
	{
		$controller = \Aimeos\Controller\Frontend::create( $this->getContext(), 'basket' );
		$products = (array) $view->param( 'b_position', [] );

		foreach( $products as $position ) {
			$controller->deleteProduct( $position );
		}

		$this->clearCached();
	}
407185
protected function filterByProperty(array $locales, $property)
    {
        $filtered = [];

        foreach ($locales as $locale) {
            if ( ! empty($locale->$property) && ! in_array($locale->$property, $filtered)) {
                $filtered[] = $locale->$property;
            }
        }

        return $filtered;
    }
777796
public function filter(array $locales)
    {
        $this->filtered = [];

        foreach ($locales as $locale) {
            $this->filterLocale($locale);
        }

        return $this->filtered;
    }
281501
private function filterLocales(array $locales)
    {
        $z = self::DEFAULT_SORT_PRIORITY;

        $filteredLocales = [];
        foreach ($locales as $langCode => $locale) {
            if (isset($locale['active']) && !$locale['active']) {
                continue;
            }

            if (!isset($locale['priority'])) {
                $locale['priority'] = $z++;
            }

            if (!isset($locale['locale'])) {
                $locale['locale'] = $langCode;
            }

            $filteredLocales[$langCode] = $locale;
        }

        return $filteredLocales;
    }
935456
public function removeProductSubscriptionsAsBuyer(\HarvestCloud\CoreBundle\Entity\ProductSubscription $productSubscription)
    {
        $this->productSubscriptionsAsBuyer->removeElement($productSubscription);
    }
1331963
public function removeProduct(\Sulu\Bundle\ProductBundle\Entity\Product $products)
    {
        $this->products->removeElement($products);
    }
1034771
public function findAllByLocale($locale, $filter = array())
    {
        if (empty($filter)) {
            $items = $this->itemRepository->findAllByLocale($locale);
        } else {
            $items = $this->itemRepository->findByLocaleAndFilter($locale, $filter);
        }

        array_walk(
            $items,
            function (&$item) use ($locale) {
                $item = $this->itemFactory->createApiEntity($item, $locale);
            }
        );

        return $items;
    }
873603
def removeProductFrom(self, userstore):
        
        def uninstall():
            #this is probably highly insufficient, but i don't know the
            #requirements
            i = userstore.findFirst(Installation,
                                    Installation.types == self.types)
            i.uninstall()
            i.deleteFromStore()
        userstore.transact(uninstall)
807186
public function removeProduct(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Product\Product $product)
    {
        return $this->products->removeElement($product);
    }
1149304
protected function createMediaForSupplierItems($items, $locale)
    {
        foreach ($items as $item) {
            if (isset($item['items']) && count($item['items'] > 0)) {
                $this->createMediaForItems($item['items'], $locale);
            }
        }
    }
645125
public function findRandomOfferedProducts($locale, $numberResults)
    {
        // Get ids of special prices.
        $specialPriceIds = $this->specialPriceRepository->findAllCurrentIds();

        if (!$specialPriceIds) {
            return [];
        }

        // Check if number of desired results does not exceed number of special prices.
        $numberOfIds = count($specialPriceIds);
        $randomIds = $specialPriceIds;
        if ($numberResults > 0 && $numberOfIds > $numberResults) {
            // Get random ids.
            $randomIds = array_map(
                function ($key) use ($specialPriceIds) {
                    return $specialPriceIds[$key];
                },
                array_rand($specialPriceIds, $numberResults)
            );
        }

        // Get special prices.
        $specialPrices = $this->specialPriceRepository->findById($randomIds);

        // Shuffle prices.
        shuffle($specialPrices);

        $products = [];
        foreach ($specialPrices as $specialPrice) {
            $product = $this->productFactory->createApiEntity($specialPrice->getProduct(), $locale);
            $this->createProductMedia($product, $locale);
            $products[] = $product;
        }

        return $products;
    }
258497
private function removeLocalizedNodeProperties(NodeInterface $node, $locale)
    {
        // remove all localized system properties from the node
        foreach ($node->getProperties($this->propertyEncoder->localizedSystemName('', $locale) . '*') as $property) {
            $property->remove();
        }

        // remove all localized content properties from the node
        foreach ($node->getProperties($this->propertyEncoder->localizedContentName('', $locale) . '*') as $property) {
            $property->remove();
        }
    }
1168093
public function setProductSubscription(\HarvestCloud\CoreBundle\Entity\ProductSubscription $productSubscription = null)
    {
        $this->productSubscription = $productSubscription;

        $productSubscription->setOriginalLineItem($this);

        return $this;
    }