/** * @param int $shopId * @param null|int $currencyId * @param null|int $customerGroupKey * @return Struct\ProductContext */ public function createProductContext($shopId, $currencyId = null, $customerGroupKey = null) { $shopContext = $this->createShopContext($shopId, $currencyId, $customerGroupKey); $locationContext = new Struct\LocationContext(null, null, null, null); $rules = $this->createTaxRulesStruct($shopContext, $locationContext->getArea(), $locationContext->getCountry(), $locationContext->getState()); $priceGroups = $this->priceGroupDiscountGateway->getPriceGroups($shopContext->getCurrentCustomerGroup(), $shopContext); return Struct\ProductContext::createFromContexts($shopContext, $rules, $priceGroups); }
/** * @param ProductContext $productContext * @param LocationContext $locationContext * @return Context */ public static function createFromContexts(ProductContext $productContext, LocationContext $locationContext) { return new self($productContext->getBaseUrl(), $productContext->getShop(), $productContext->getCurrency(), $productContext->getCurrentCustomerGroup(), $productContext->getFallbackCustomerGroup(), $productContext->getTaxRules(), $productContext->getPriceGroups(), $locationContext->getArea(), $locationContext->getCountry(), $locationContext->getState()); }
/** * @param $number * @param ProductContext $context * @param Category $category * @return array */ protected function getProduct($number, ProductContext $context, Category $category = null) { $product = $this->helper->getSimpleProduct($number, array_shift($context->getTaxRules()), $context->getCurrentCustomerGroup()); $product['categories'] = [['id' => $context->getShop()->getCategory()->getId()]]; if ($category) { $product['categories'] = array(array('id' => $category->getId())); } return $product; }