/**
  * Assert that event block is absent on category/product pages.
  *
  * @param CmsIndex $cmsIndex
  * @param CatalogCategoryView $catalogCategoryView
  * @param CatalogProductSimple $product
  * @param CatalogProductView $catalogProductView
  * @param Cache $adminCache
  * @return void
  */
 public function processAssert(CmsIndex $cmsIndex, CatalogCategoryView $catalogCategoryView, CatalogProductSimple $product, CatalogProductView $catalogProductView, Cache $adminCache)
 {
     // Flush cache
     $adminCache->open();
     $adminCache->getPageActions()->flushCacheStorage();
     $adminCache->getMessagesBlock()->waitSuccessMessage();
     $categoryName = $product->getCategoryIds()[0];
     $cmsIndex->open();
     $cmsIndex->getTopmenu()->selectCategory($categoryName);
     \PHPUnit_Framework_Assert::assertFalse($catalogCategoryView->getEventBlock()->isVisible(), "Event block is present on Category page.");
     $cmsIndex->open();
     $cmsIndex->getTopmenu()->selectCategory($categoryName);
     $catalogCategoryView->getListProductBlock()->openProductViewPage($product->getName());
     \PHPUnit_Framework_Assert::assertFalse($catalogProductView->getEventBlock()->isVisible(), "Event block is present on Product page.");
 }
 /**
  * Assert that apache redirect works by opening category page and asserting index.php in its url.
  *
  * @param CatalogCategory $category
  * @param CmsIndex $homePage
  * @param BrowserInterface $browser
  */
 public function processAssert(CatalogCategory $category, CmsIndex $homePage, BrowserInterface $browser)
 {
     $category->persist();
     $homePage->open();
     $homePage->getTopmenu()->selectCategory($category->getName());
     \PHPUnit_Framework_Assert::assertTrue(strpos($browser->getUrl(), 'index.php') === false, 'Apache redirect for category does not work.');
 }
 /**
  * Assert that products' MAP has been applied before checkout.
  *
  * @param CatalogCategory $category
  * @param Customer $customer
  * @param Address $address
  * @param CatalogCategoryView $catalogCategoryView
  * @param CmsIndex $cmsIndex
  * @param CatalogProductView $catalogProductView
  * @param CheckoutCart $cart
  * @param CheckoutOnepage $checkoutOnePage
  * @param array $products
  * @return void
  */
 public function processAssert(CatalogCategory $category, Customer $customer, Address $address, CatalogCategoryView $catalogCategoryView, CmsIndex $cmsIndex, CatalogProductView $catalogProductView, CheckoutCart $cart, CheckoutOnepage $checkoutOnePage, array $products)
 {
     for ($i = 0; $i < count($products); $i++) {
         $cart->getCartBlock()->clearShoppingCart();
         $productName = $products[$i]->getName();
         $cmsIndex->open();
         $cmsIndex->getTopmenu()->selectCategory($category->getName());
         // Check that price is not present on category page.
         $listProductBlock = $catalogCategoryView->getListProductBlock();
         $productPriceBlock = $listProductBlock->getProductPriceBlock($productName);
         $productPriceBlock->clickForPrice();
         \PHPUnit_Framework_Assert::assertFalse($productPriceBlock->getMapBlock()->isPriceVisible(), 'Price is present in MSRP dialog on category page.');
         // Check that price is not present on product page.
         $listProductBlock->openProductViewPage($productName);
         \PHPUnit_Framework_Assert::assertFalse($catalogProductView->getViewBlock()->getPriceBlock()->isRegularPriceVisible(), 'Price is present in View block on product page.');
         // Check that price is not present on cart.
         $catalogProductView->getViewBlock()->addToCart($products[$i]);
         \PHPUnit_Framework_Assert::assertTrue($cart->getCartBlock()->getCartItem($products[$i])->isMsrpVisible(), "MSRP link is not visible in cart.");
         // Check that price is present on review block in onepage checkout page.
         $cart->getCartBlock()->getProceedToCheckoutBlock()->proceedToCheckout();
         $checkoutMethodBlock = $checkoutOnePage->getLoginBlock();
         $billingBlock = $checkoutOnePage->getBillingBlock();
         $paymentMethodBlock = $checkoutOnePage->getPaymentMethodsBlock();
         $shippingBlock = $checkoutOnePage->getShippingMethodBlock();
         $checkoutMethodBlock->guestCheckout();
         $checkoutMethodBlock->clickContinue();
         $billingBlock->fillBilling($address, $customer);
         $billingBlock->clickContinue();
         $shippingBlock->selectShippingMethod(['shipping_service' => 'Flat Rate', 'shipping_method' => 'Fixed']);
         $shippingBlock->clickContinue();
         $paymentMethodBlock->selectPaymentMethod(['method' => 'checkmo']);
         $paymentMethodBlock->clickContinue();
         \PHPUnit_Framework_Assert::assertEquals(number_format($products[$i]->getPrice(), 2), $checkoutOnePage->getReviewBlock()->getTotalBlock()->getData('subtotal'), "Subtotal in checkout one page for {$productName} is not equal to expected.");
     }
 }
 /**
  * Event block has $this->eventStatus on Product Page.
  *
  * @return void
  */
 protected function checkEventStatusOnProductPage()
 {
     $categoryName = $this->product->getDatafieldConfig('category_ids')['source']->getProductCategory()->getName();
     $this->cmsIndex->open();
     $this->cmsIndex->getTopmenu()->selectCategory($categoryName);
     $this->catalogCategoryView->getListProductBlock()->openProductViewPage($this->product->getName());
     \PHPUnit_Framework_Assert::assertEquals($this->eventStatus, $this->catalogProductView->getEventBlock()->getEventStatus(), 'Wrong event status is displayed.');
 }
 /**
  * Assert that Catalog Price Rule is applied for product(s) in Shopping Cart
  * according to Priority(Priority/Stop Further Rules Processing).
  *
  * @param InjectableFixture $product
  * @param CatalogProductView $pageCatalogProductView
  * @param CmsIndex $cmsIndex
  * @param CatalogCategoryView $catalogCategoryView
  * @param CheckoutCart $pageCheckoutCart
  * @param array $prices
  * @return void
  */
 public function processAssert(InjectableFixture $product, CatalogProductView $pageCatalogProductView, CmsIndex $cmsIndex, CatalogCategoryView $catalogCategoryView, CheckoutCart $pageCheckoutCart, array $prices)
 {
     $cmsIndex->open();
     $cmsIndex->getTopmenu()->selectCategory($product->getCategoryIds()[0]);
     $catalogCategoryView->getListProductBlock()->openProductViewPage($product->getName());
     $pageCatalogProductView->getViewBlock()->addToCart($product);
     $actualGrandTotal = $pageCheckoutCart->getCartBlock()->getCartItem($product)->getCartItemTypePrice('price');
     \PHPUnit_Framework_Assert::assertEquals($prices['grand_total'], $actualGrandTotal);
 }
 /**
  * Assert that Catalog Price Rule is applied for product(s) in Catalog
  * according to Priority(Priority/Stop Further Rules Processing).
  *
  * @param InjectableFixture $product
  * @param CmsIndex $cmsIndex
  * @param CatalogCategoryView $catalogCategoryView
  * @param array $prices
  * @return void
  */
 public function processAssert(InjectableFixture $product, CmsIndex $cmsIndex, CatalogCategoryView $catalogCategoryView, array $prices)
 {
     $cmsIndex->open();
     $cmsIndex->getTopmenu()->selectCategory($product->getCategoryIds()[0]);
     $formPrices = $this->getFormPrices($product, $catalogCategoryView);
     $fixturePrices = $this->prepareFixturePrices($prices);
     $diff = $this->verifyData($fixturePrices, $formPrices);
     \PHPUnit_Framework_Assert::assertEmpty($diff, $diff . "\n On: " . date('l jS \\of F Y h:i:s A'));
 }
 /**
  * Check event block on visibility on specified page.
  *
  * @param string $page
  * @param bool $positive [optional]
  * @return void
  */
 protected function checkEventBlockOnPage($page, $positive = true)
 {
     $this->cmsIndex->open();
     $this->cmsIndex->getTopmenu()->selectCategory($this->categoryName);
     if ($page == 'product_page') {
         $this->catalogCategoryView->getListProductBlock()->openProductViewPage($this->productName);
     }
     $eventBlockVisibility = $this->catalogProductView->getEventBlock()->isVisible();
     $positive == true ? \PHPUnit_Framework_Assert::assertTrue($eventBlockVisibility, "EventBlock is absent on {$page} page.") : \PHPUnit_Framework_Assert::assertFalse($eventBlockVisibility, "EventBlock is present on {$page} page.");
 }
 /**
  * Assert that created CMS block displayed on frontend category page (in order to assign block to category:
  * go to category page> Display settings> CMS Block).
  *
  * @param CmsIndex $cmsIndex
  * @param CmsBlock $cmsBlock
  * @param CatalogCategoryView $catalogCategoryView
  * @param FixtureFactory $fixtureFactory
  * @return void
  */
 public function processAssert(CmsIndex $cmsIndex, CmsBlock $cmsBlock, CatalogCategoryView $catalogCategoryView, FixtureFactory $fixtureFactory)
 {
     $category = $fixtureFactory->createByCode('catalogCategory', ['dataSet' => 'default_subcategory', 'data' => ['display_mode' => 'Static block and products', 'landing_page' => $cmsBlock->getTitle()]]);
     $category->persist();
     $cmsIndex->open();
     $cmsIndex->getTopmenu()->selectCategory($category->getName());
     $categoryViewContent = $catalogCategoryView->getViewBlock()->getText();
     $cmsBlockContent = explode("\n", $categoryViewContent);
     \PHPUnit_Framework_Assert::assertContains($cmsBlock->getContent(), $cmsBlockContent);
 }
 /**
  * Assert that product is absent in the category page.
  *
  * @param CatalogCategoryView $catalogCategoryView
  * @param CmsIndex $cmsIndex
  * @param InjectableFixture $product
  * @param CatalogCategory $category
  * @return void
  */
 public function processAssert(CatalogCategoryView $catalogCategoryView, CmsIndex $cmsIndex, InjectableFixture $product, CatalogCategory $category)
 {
     $cmsIndex->open();
     $cmsIndex->getTopmenu()->selectCategory($category->getName());
     $isProductVisible = $catalogCategoryView->getListProductBlock()->isProductVisible($product);
     while (!$isProductVisible && $catalogCategoryView->getBottomToolbar()->nextPage()) {
         $isProductVisible = $catalogCategoryView->getListProductBlock()->isProductVisible($product);
     }
     \PHPUnit_Framework_Assert::assertFalse($isProductVisible, 'Product is present on category page.');
 }
 /**
  * Get prices on category page.
  *
  * @return array
  */
 protected function getCategoryPrice()
 {
     $prices = [];
     $this->cmsIndex->open();
     $this->cmsIndex->getTopmenu()->selectCategory($this->product->getCategoryIds()[0]);
     $priceBlock = $this->catalogCategoryView->getWeeeListProductBlock()->getProductItem($this->product)->getPriceBlock();
     foreach ($this->expectedPrices['category'] as $key => $type) {
         $prices[$key] = $this->getPrice($priceBlock, $key);
     }
     return $prices;
 }
 /**
  * Assert that out of stock product is visible in the assigned category.
  *
  * @param CatalogCategoryView $catalogCategoryView
  * @param CmsIndex $cmsIndex
  * @param InjectableFixture $product
  * @param CatalogCategory|null $category
  * @return void
  */
 public function processAssert(CatalogCategoryView $catalogCategoryView, CmsIndex $cmsIndex, InjectableFixture $product, CatalogCategory $category = null)
 {
     $categoryName = $product->hasData('category_ids') ? $product->getCategoryIds()[0] : $category->getName();
     $cmsIndex->open();
     $cmsIndex->getTopmenu()->selectCategory($categoryName);
     $isProductVisible = $catalogCategoryView->getListProductBlock()->isProductVisible($product);
     while (!$isProductVisible && $catalogCategoryView->getBottomToolbar()->nextPage()) {
         $isProductVisible = $catalogCategoryView->getListProductBlock()->isProductVisible($product);
     }
     \PHPUnit_Framework_Assert::assertTrue($isProductVisible, "Product is absent on category page.");
 }
 /**
  * Assert that after applying changes, currency symbol changed on Catalog page.
  *
  * @param CmsIndex $cmsIndex
  * @param CatalogCategoryView $catalogCategoryView
  * @param CatalogProductSimple $product
  * @param CurrencySymbolEntity $currencySymbol
  * @return void
  */
 public function processAssert(CmsIndex $cmsIndex, CatalogCategoryView $catalogCategoryView, CatalogProductSimple $product, CurrencySymbolEntity $currencySymbol)
 {
     $categoryName = $product->getCategoryIds()[0];
     $cmsIndex->open();
     $cmsIndex->getCurrencyBlock()->switchCurrency($currencySymbol);
     $cmsIndex->getTopmenu()->selectCategory($categoryName);
     $price = $catalogCategoryView->getListProductBlock()->getPrice($product->getId());
     preg_match('`(.*?)\\d`', $price, $matches);
     $symbolOnPage = isset($matches[1]) ? $matches[1] : null;
     \PHPUnit_Framework_Assert::assertEquals($currencySymbol->getCustomCurrencySymbol(), $symbolOnPage, 'Wrong Currency Symbol is displayed on Category page.');
 }
 /**
  * Assert that Catalog Price Rule is applied & it impacts on product's discount price on Product page.
  *
  * @param InjectableFixture $product
  * @param CatalogProductView $pageCatalogProductView
  * @param CmsIndex $cmsIndex
  * @param CatalogCategoryView $catalogCategoryView
  * @param array $prices
  * @return void
  */
 public function processAssert(InjectableFixture $product, CatalogProductView $pageCatalogProductView, CmsIndex $cmsIndex, CatalogCategoryView $catalogCategoryView, array $prices)
 {
     $cmsIndex->open();
     $cmsIndex->getTopmenu()->selectCategory($product->getCategoryIds()[0]);
     $catalogCategoryView->getListProductBlock()->openProductViewPage($product->getName());
     $productPriceBlock = $pageCatalogProductView->getViewBlock()->getPriceBlock();
     $actualPrices['regular'] = $productPriceBlock->getRegularPrice();
     $actualPrices['special'] = $productPriceBlock->getSpecialPrice();
     $actualPrices['discount_amount'] = number_format($actualPrices['regular'] - $actualPrices['special'], 2);
     $diff = $this->verifyData($actualPrices, $prices);
     \PHPUnit_Framework_Assert::assertEmpty($diff, $diff);
 }
 /**
  * Assert that products are absent in category frontend page.
  *
  * @param CatalogCategoryView $catalogCategoryView
  * @param CmsIndex $cmsIndex
  * @param CatalogCategory $category
  * @param array $unassignedProducts
  * @return void
  */
 public function processAssert(CatalogCategoryView $catalogCategoryView, CmsIndex $cmsIndex, CatalogCategory $category, array $unassignedProducts)
 {
     $cmsIndex->open();
     $cmsIndex->getTopmenu()->selectCategory($category->getName());
     foreach ($unassignedProducts as $product) {
         $isProductVisible = $catalogCategoryView->getListProductBlock()->isProductVisible($product);
         while (!$isProductVisible && $catalogCategoryView->getBottomToolbar()->nextPage()) {
             $isProductVisible = $catalogCategoryView->getListProductBlock()->isProductVisible($product);
         }
         \PHPUnit_Framework_Assert::assertFalse($isProductVisible, "Product {$product->getName()} is present in category page.");
     }
 }
 /**
  * Assert that created Order By Sku widget displayed on frontend in Catalog.
  *
  * @param CatalogCategory $category
  * @param CmsIndex $cmsIndex
  * @param CatalogCategoryView $catalogCategoryView
  * @param Widget $widget
  * @param Cache $adminCache
  * @return void
  */
 public function processAssert(CatalogCategory $category, CmsIndex $cmsIndex, CatalogCategoryView $catalogCategoryView, Widget $widget, Cache $adminCache)
 {
     $category->persist();
     // Flush cache
     $adminCache->open();
     $adminCache->getPageActions()->flushCacheStorage();
     $adminCache->getMessagesBlock()->waitSuccessMessage();
     $cmsIndex->open();
     $cmsIndex->getTopmenu()->selectCategory($category->getName());
     $errors = $catalogCategoryView->getWidgetView()->checkWidget($widget, "Order by SKU");
     \PHPUnit_Framework_Assert::assertEmpty($errors, $errors);
 }
 /**
  * Assert that banner presents on specific category page.
  *
  * @param CatalogProductSimple $product
  * @param CmsIndex $cmsIndex
  * @param Banner $banner
  * @param CatalogCategoryView $catalogCategoryView
  * @param Customer $customer[optional]
  * @param Cache $adminCache
  * @return void
  */
 public function processAssert(CatalogProductSimple $product, CmsIndex $cmsIndex, Banner $banner, CatalogCategoryView $catalogCategoryView, Customer $customer = null, Cache $adminCache)
 {
     // Flush cache
     $adminCache->open();
     $adminCache->getPageActions()->flushCacheStorage();
     $adminCache->getMessagesBlock()->waitSuccessMessage();
     if ($customer !== null) {
         $this->objectManager->create('Mage\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $customer])->run();
     } else {
         $cmsIndex->open();
     }
     $cmsIndex->getTopmenu()->selectCategory($product->getCategoryIds()[0]);
     \PHPUnit_Framework_Assert::assertTrue($catalogCategoryView->getBannerViewBlock()->checkWidgetBanners($banner), 'Banner is absent on Category page.');
 }
 /**
  * Assert that product products' MAP has been applied on gesture.
  *
  * @param CatalogCategoryView $catalogCategoryView
  * @param CmsIndex $cmsIndex
  * @param CatalogCategory $category
  * @param array $products
  * @return void
  */
 public function processAssert(CatalogCategoryView $catalogCategoryView, CmsIndex $cmsIndex, CatalogCategory $category, array $products)
 {
     foreach ($products as $product) {
         $productName = $product->getName();
         $cmsIndex->open();
         $cmsIndex->getTopmenu()->selectCategory($category->getName());
         $listProductBlock = $catalogCategoryView->getListProductBlock();
         // Check that price is present in MAP popup.
         $productPriceBlock = $listProductBlock->getProductPriceBlock($productName);
         $productPriceBlock->clickForPrice();
         $msrpPopupBlock = $productPriceBlock->getMapBlock();
         $map = $msrpPopupBlock->isVisible() ? $msrpPopupBlock->getMap() : null;
         \PHPUnit_Framework_Assert::assertEquals(number_format($product->getPrice(), 2), $map, "MAP of {$productName} product is not visible or not equal to product price.");
     }
 }
 /**
  * Assert that product is visible in the assigned category.
  *
  * @param CatalogCategoryView $catalogCategoryView
  * @param CmsIndex $cmsIndex
  * @param InjectableFixture $product
  * @param CatalogCategory|null $category
  * @return void
  *
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function processAssert(CatalogCategoryView $catalogCategoryView, CmsIndex $cmsIndex, InjectableFixture $product, CatalogCategory $category = null)
 {
     $categoryName = $product->hasData('category_ids') ? $product->getCategoryIds()[0] : $category->getName();
     $cmsIndex->open();
     $cmsIndex->getTopmenu()->selectCategory($categoryName);
     $isProductVisible = $catalogCategoryView->getListProductBlock()->isProductVisible($product);
     while (!$isProductVisible && $catalogCategoryView->getBottomToolbar()->nextPage()) {
         $isProductVisible = $catalogCategoryView->getListProductBlock()->isProductVisible($product);
     }
     if ($product->getVisibility() === 'Search' || $this->getStockStatus($product) === 'Out of Stock') {
         $isProductVisible = !$isProductVisible;
         $this->errorMessage = 'Product found in this category.';
         $this->successfulMessage = 'Asserts that the product could not be found in this category.';
     }
     \PHPUnit_Framework_Assert::assertTrue($isProductVisible, $this->errorMessage);
 }
 /**
  * Checking the product in the page of its price.
  *
  * @param CatalogCategoryView $catalogCategoryView
  * @param CmsIndex $cmsIndex
  * @param InjectableFixture $product
  * @param CatalogCategory $category
  * @return void
  */
 public function processAssert(CatalogCategoryView $catalogCategoryView, CmsIndex $cmsIndex, InjectableFixture $product, CatalogCategory $category)
 {
     // Open category view page and check visible product
     $categoryName = $category->getName();
     if ($product->hasData('category_ids')) {
         $categoryIds = $product->getCategoryIds();
         $categoryName = is_array($categoryIds) ? reset($categoryIds) : $categoryName;
     }
     $cmsIndex->open();
     $cmsIndex->getTopmenu()->selectCategory($categoryName);
     $isProductVisible = $catalogCategoryView->getListProductBlock()->isProductVisible($product);
     while (!$isProductVisible && $catalogCategoryView->getBottomToolbar()->nextPage()) {
         $isProductVisible = $catalogCategoryView->getListProductBlock()->isProductVisible($product);
     }
     \PHPUnit_Framework_Assert::assertTrue($isProductVisible, 'Product is absent on category page.');
     //Process price asserts
     $this->assertPrice($product, $catalogCategoryView);
 }
 /**
  * Assert that product products' MAP has been applied in cart.
  *
  * @param CatalogCategoryView $catalogCategoryView
  * @param CmsIndex $cmsIndex
  * @param CatalogCategory $category
  * @param CatalogProductView $catalogProductView
  * @param CheckoutCart $cart
  * @param array $products
  * @return void
  */
 public function processAssert(CatalogCategoryView $catalogCategoryView, CmsIndex $cmsIndex, CatalogCategory $category, CatalogProductView $catalogProductView, CheckoutCart $cart, array $products)
 {
     foreach ($products as $product) {
         $cart->getCartBlock()->clearShoppingCart();
         $productName = $product->getName();
         $cmsIndex->open();
         $cmsIndex->getTopmenu()->selectCategory($category->getName());
         $listProductBlock = $catalogCategoryView->getListProductBlock();
         // Check that price is not present on category page.
         $productPriceBlock = $listProductBlock->getProductPriceBlock($productName);
         $productPriceBlock->clickForPrice();
         \PHPUnit_Framework_Assert::assertFalse($productPriceBlock->getMapBlock()->isPriceVisible(), 'Price is present in MSRP dialog on category page.');
         // Check that price is not present on product page.
         $listProductBlock->openProductViewPage($productName);
         \PHPUnit_Framework_Assert::assertFalse($catalogProductView->getViewBlock()->getPriceBlock()->isRegularPriceVisible(), 'Price is present in View block on product page.');
         // Check that price is present in cart.
         $catalogProductView->getViewBlock()->addToCart($product);
         \PHPUnit_Framework_Assert::assertEquals(number_format($product->getPrice(), 2), $cart->getCartBlock()->getCartItem($product)->getCartItemTypePrice('price'), "MAP of {$productName} product in cart is not equal to product price.");
     }
 }
 /**
  * Assert that widget catalog event carousel is present on category page and link "Go To Sale" on widget redirects
  * you to category page.
  *
  * @param CmsIndex $cmsIndex
  * @param CatalogEventWidget $widget
  * @param CatalogCategoryView $catalogCategoryView
  * @param Cache $adminCache
  * @param CatalogEvent $event1
  * @param CatalogEvent $event2
  * @return void
  */
 public function processAssert(CmsIndex $cmsIndex, CatalogEventWidget $widget, CatalogCategoryView $catalogCategoryView, Cache $adminCache, CatalogEvent $event1, CatalogEvent $event2)
 {
     // Flush cache
     $adminCache->open();
     $adminCache->getPageActions()->flushCacheStorage();
     $adminCache->getMessagesBlock()->waitSuccessMessage();
     $event1->persist();
     $event2->persist();
     $cmsIndex->open();
     $categoryName = $event2->getCategoryId();
     $cmsIndex->getTopmenu()->selectCategory($categoryName);
     $errors = $catalogCategoryView->getWidgetView()->checkWidget($widget, $categoryName);
     \PHPUnit_Framework_Assert::assertEmpty($errors, implode(" ", $errors));
     $cmsIndex->open();
     $cmsIndex->getWidgetView()->clickToWidget($widget, $categoryName);
     $pageTitle = $cmsIndex->getCmsPageBlock()->getPageTitle();
     $expected = strtolower($categoryName);
     $actual = strtolower($pageTitle);
     \PHPUnit_Framework_Assert::assertEquals($expected, $actual, "Wrong page title on Category page: expected = '{$expected}', actual = '{$actual}'");
 }
 /**
  * Open product category.
  *
  * @param CatalogProductSimple $product
  * @return void
  */
 protected function openCategory(CatalogProductSimple $product)
 {
     $this->cmsIndex->open();
     $this->cmsIndex->getTopmenu()->selectCategory($product->getCategoryIds()[0]);
 }