/** * @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; }