Skip to content

Commit

Permalink
Add schedule and url datas on availability map block (#75)
Browse files Browse the repository at this point in the history
Co-authored-by: Cédric Magrez <cedric.magrez@smile.fr>
  • Loading branch information
cemag44300 and cemag44 authored Apr 22, 2024
1 parent fd4c82a commit 7be5d4a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Block/Catalog/Product/Retailer/Availability.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
use Smile\Retailer\Api\Data\RetailerInterface;
use Smile\Retailer\Model\ResourceModel\Retailer\CollectionFactory as RetailerCollectionFactory;
use Smile\RetailerOffer\Helper\Config as HelperConfig;
use Smile\StoreLocator\Helper\Data;
use Smile\StoreLocator\Helper\Schedule;
use Smile\StoreLocator\Model\Retailer\ScheduleManagement;

/**
* Block rendering availability in store for a given product.
Expand All @@ -43,6 +46,9 @@ public function __construct(
protected Region $region,
protected HelperConfig $helperConfig,
MapProviderInterface $mapProvider,
protected ScheduleManagement $scheduleManagement,
protected Schedule $scheduleHelper,
protected Data $storeLocatorHelper,
array $data = []
) {
$this->map = $mapProvider->getMap();
Expand Down Expand Up @@ -154,8 +160,18 @@ protected function getStoreOffers(): array
'longitude' => $address->getCoordinates()->getLongitude(),
'setStoreData' => $this->getSetStorePostData($retailer),
'isAvailable' => false,
'url' => $this->storeLocatorHelper->getRetailerUrl($retailer),
];

$offer['schedule'] = array_merge(
$this->scheduleHelper->getConfig(),
[
'calendar' => $this->scheduleManagement->getCalendar($retailer),
'openingHours' => $this->scheduleManagement->getWeekOpeningHours($retailer),
'specialOpeningHours' => $retailerExtensionInterface->getSpecialOpeningHours(),
]
);

if (isset($offerByRetailer[(int) $retailer->getId()])) {
$offer['isAvailable'] = (bool) $offerByRetailer[(int) $retailer->getId()]->isAvailable();
$offer[OfferInterface::OFFER_ID] = $offerByRetailer[(int) $retailer->getId()]->getId();
Expand Down

0 comments on commit 7be5d4a

Please sign in to comment.