Skip to content

Commit

Permalink
Merge pull request #32 from magmodules/release/1.12.0
Browse files Browse the repository at this point in the history
Release/1.12.0
  • Loading branch information
Marvin-Magmodules authored Dec 5, 2024
2 parents e7d5bcf + 175ce81 commit 7ae619f
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 10 deletions.
15 changes: 13 additions & 2 deletions Service/WebApi/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ private function getCollection(
*
* @return array|null
*/
private function getProfileData($order): ?array
private function getProfileData(OrderModel $order): ?array
{
try {
if ($order->getCustomerId()) {
Expand All @@ -146,13 +146,24 @@ private function getProfileData($order): ?array
'email' => $customer->getEmail()
];
} else {
return [
$data = [
'id' => null,
'customer_firstname' => $order->getCustomerFirstname(),
'customer_middlename' => $order->getCustomerMiddlename(),
'customer_lastname' => $order->getCustomerLastname(),
'email' => $order->getCustomerEmail()
];
if ($shipAddress = $order->getShippingAddress()) {
$data['region_id'] = $shipAddress->getRegionId();
$data['region'] = $shipAddress->getRegion();
$data['postcode'] = $shipAddress->getPostcode();
$data['street'] = $shipAddress->getStreet();
$data['city'] = $shipAddress->getCity();
$data['telephone'] = $shipAddress->getTelephone();
$data['country_id'] = $shipAddress->getCountryId();
$data['company'] = $shipAddress->getCompany();
}
return $data;
}
} catch (\Exception $exception) {
return null;
Expand Down
40 changes: 35 additions & 5 deletions Service/WebApi/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,17 +252,47 @@ private function applyFilter(Collection $products, array $filters, int $storeId
}

/**
* @param $product
* Get the main image URL for a product.
*
* @return string
* @param \Magento\Catalog\Model\Product $product The product instance.
* @return string The full URL of the product's main image, or an empty string if no image exists.
*/
private function getMainImage($product)
private function getMainImage($product): string
{
if ($image = $product->getImage()) {
return $this->getMediaBaseUrl($product->getStoreId())
. 'catalog/product'
. $this->normalizeImagePath($image);
}

return '';
}

/**
* Retrieve the base URL for media files for a specific store.
*
* @param int $storeId The store ID.
* @return string The base media URL for the store.
*/
private function getMediaBaseUrl(int $storeId): string
{
if (!$this->mediaPath) {
$this->mediaPath = $this->storeManager->getStore($product->getStoreId())
$this->mediaPath = $this->storeManager->getStore($storeId)
->getBaseUrl(UrlInterface::URL_TYPE_MEDIA);
}
return $this->mediaPath . 'catalog/product' . $product->getImage();

return $this->mediaPath;
}

/**
* Normalize the image path by ensuring it starts with a forward slash.
*
* @param string $image The image path from the product.
* @return string The normalized image path.
*/
private function normalizeImagePath(string $image): string
{
return '/' . ltrim($image, '/');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Service/WebApi/Profiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public function execute(int $storeId, array $extra = [], SearchCriteriaInterface
"active" => true,
"subscribed_to_newsletter" => $this->isSubscribed($customer),
"birthdate" => $customer->getDob(),
"customer_group" => $customerGroups[$customer->getGroupId()] ?? ''
"eav_customer_group" => $customerGroups[$customer->getGroupId()] ?? ''
];

if ($billingId = $customer->getDefaultBilling()) {
Expand Down
1 change: 1 addition & 0 deletions Service/WebApi/Variants.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ public function execute(int $storeId, array $extra = [], SearchCriteriaInterface
"price_excl" => $product->getPrice(),
"price_incl" => $product->getPrice(),
"unit_price" => $product->getPrice(),
"special_price" => $product->getSpecialPrice(),
"sku" => $this->getAttributeValue($product, $sku),
"brand" => $this->getAttributeValue($product, $brand),
"stock_level" => $this->getStockLevel($product, $stockData, $websiteId),
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "magmodules/magento2-reloadify",
"description": "Reloadify extension for Magento 2",
"type": "magento2-module",
"version": "1.11.0",
"version": "1.12.0",
"license": [
"BSD-2-Clause"
],
Expand Down
2 changes: 1 addition & 1 deletion etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<default>
<magmodules_reloadify>
<general>
<version>v1.11.0</version>
<version>v1.12.0</version>
<enable>0</enable>
<debug>0</debug>
</general>
Expand Down

0 comments on commit 7ae619f

Please sign in to comment.