isLoggedIn()) { $this->pageConfig->addBodyClass('lts-customer-logged-in'); } return parent::_prepareLayout(); } public function isLoggedIn(): bool { return $this->customerSession->isLoggedIn(); } public function getCustomerName(): string { return trim((string) $this->customerSession->getCustomer()->getName()); } public function getRecentOrders() { return $this->orderCollectionFactory->create() ->addFieldToFilter('customer_id', (int) $this->customerSession->getCustomerId()) ->setOrder('created_at', 'DESC') ->setPageSize(2); } public function getWishlistItems(): array { $wishlist = $this->wishlistFactory->create() ->loadByCustomerId((int) $this->customerSession->getCustomerId(), true); $items = []; foreach ($wishlist->getItemCollection() as $item) { $items[] = $item; if (count($items) === 3) { break; } } return $items; } public function getOrderImages($order): array { $images = []; foreach ($order->getAllVisibleItems() as $item) { $product = $item->getProduct(); if ($product && $product->getId()) { $images[] = $this->imageHelper->init($product, 'product_thumbnail_image') ->resize(42, 42) ->getUrl(); } if (count($images) === 2) { break; } } return $images; } public function getBranchName(): string { $address = $this->customerSession->getCustomer()->getDefaultBillingAddress(); $city = $address ? trim((string) $address->getCity()) : ''; return $city !== '' ? $city . ' Branch' : (string) __('My Local Branch'); } public function getBranchAddress(): string { $address = $this->customerSession->getCustomer()->getDefaultBillingAddress(); if (!$address) { return (string) __('Add a default billing address in My Account'); } $parts = array_filter([ implode(' ', (array) $address->getStreet()), trim(implode(' ', [(string) $address->getCity(), (string) $address->getRegion(), (string) $address->getPostcode()])) ]); return implode(', ', $parts); } }