Skip to content

Commit 78bb905

Browse files
authored
Merge pull request #78 from mageplaza/2.3-develop
Clean code
2 parents e170130 + f0a038e commit 78bb905

File tree

8 files changed

+110
-112
lines changed

8 files changed

+110
-112
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

+34-34
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
1-
---
2-
name: Bug report
3-
about: Technical issue with the extension
4-
labels: 'Issue'
5-
6-
---
7-
8-
<!---
9-
Fields marked with (*) are required. Please don't remove the template.
10-
-->
11-
12-
### Preconditions (*)
13-
<!---
14-
Provide the exact Magento version (example: 2.4.0) and any important information on the environment where bug is reproducible.
15-
-->
16-
1.
17-
2.
18-
19-
### Steps to reproduce (*)
20-
<!---
21-
Important: Provide a set of clear steps to reproduce this bug. We can not provide support without clear instructions on how to reproduce.
22-
-->
23-
1.
24-
2.
25-
26-
### Expected result (*)
27-
<!--- Tell us what do you expect to happen. -->
28-
1. [Screenshots, logs or description]
29-
2.
30-
31-
### Actual result (*)
32-
<!--- Tell us what happened instead. Include error messages and issues. -->
33-
1. [Screenshots, logs or description]
34-
2.
1+
---
2+
name: Bug report
3+
about: Technical issue with the extension
4+
labels: 'Issue'
5+
6+
---
7+
8+
<!---
9+
Fields marked with (*) are required. Please don't remove the template.
10+
-->
11+
12+
### Preconditions (*)
13+
<!---
14+
Provide the exact Magento version (example: 2.4.0) and any important information on the environment where bug is reproducible.
15+
-->
16+
1.
17+
2.
18+
19+
### Steps to reproduce (*)
20+
<!---
21+
Important: Provide a set of clear steps to reproduce this bug. We can not provide support without clear instructions on how to reproduce.
22+
-->
23+
1.
24+
2.
25+
26+
### Expected result (*)
27+
<!--- Tell us what do you expect to happen. -->
28+
1. [Screenshots, logs or description]
29+
2.
30+
31+
### Actual result (*)
32+
<!--- Tell us what happened instead. Include error messages and issues. -->
33+
1. [Screenshots, logs or description]
34+
2.
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
---
2-
name: Developer experience issue
3-
about: Issues related to customization, extensibility, modularity
4-
labels: 'Experience'
5-
6-
---
7-
8-
<!---
9-
Fields marked with (*) are required. Please don't remove the template.
10-
-->
11-
12-
### Summary (*)
13-
<!--- Describe the issue you are experiencing. Include general information, error messages, environments, and so on. -->
14-
15-
### Examples (*)
16-
<!--- Provide code examples or a patch with a test (recommended) to clearly indicate the problem. -->
17-
18-
### Proposed solution
19-
<!--- Suggest your potential solutions for this issue. -->
1+
---
2+
name: Developer experience issue
3+
about: Issues related to customization, extensibility, modularity
4+
labels: 'Experience'
5+
6+
---
7+
8+
<!---
9+
Fields marked with (*) are required. Please don't remove the template.
10+
-->
11+
12+
### Summary (*)
13+
<!--- Describe the issue you are experiencing. Include general information, error messages, environments, and so on. -->
14+
15+
### Examples (*)
16+
<!--- Provide code examples or a patch with a test (recommended) to clearly indicate the problem. -->
17+
18+
### Proposed solution
19+
<!--- Suggest your potential solutions for this issue. -->
+22-22
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
---
2-
name: Feature request
3-
about: Request feature for development
4-
labels: 'Feature Request'
5-
6-
---
7-
8-
<!---
9-
Fields marked with (*) are required. Please don't remove the template.
10-
-->
11-
12-
### Description (*)
13-
<!--- Describe the feature you would like to add. -->
14-
15-
### Expected behavior (*)
16-
<!--- What is the expected behavior of this feature? How is it going to work? -->
17-
18-
### Benefits
19-
<!--- How do you think this feature would improve the extension? -->
20-
21-
### Additional information
22-
<!--- What other information can you provide about the desired feature? -->
1+
---
2+
name: Feature request
3+
about: Request feature for development
4+
labels: 'Feature Request'
5+
6+
---
7+
8+
<!---
9+
Fields marked with (*) are required. Please don't remove the template.
10+
-->
11+
12+
### Description (*)
13+
<!--- Describe the feature you would like to add. -->
14+
15+
### Expected behavior (*)
16+
<!--- What is the expected behavior of this feature? How is it going to work? -->
17+
18+
### Benefits
19+
<!--- How do you think this feature would improve the extension? -->
20+
21+
### Additional information
22+
<!--- What other information can you provide about the desired feature? -->

Block/AbstractSlider.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ private function getPriceCurrency()
176176
$this->priceCurrency = ObjectManager::getInstance()
177177
->get(PriceCurrencyInterface::class);
178178
}
179+
179180
return $this->priceCurrency;
180181
}
181182

@@ -234,10 +235,10 @@ public function getProductPriceHtml(
234235
if (!isset($arguments['zone'])) {
235236
$arguments['zone'] = $renderZone;
236237
}
237-
$arguments['price_id'] = isset($arguments['price_id'])
238+
$arguments['price_id'] = isset($arguments['price_id'])
238239
? $arguments['price_id']
239240
: 'old-price-' . $product->getId() . '-' . $priceType;
240-
$arguments['include_container'] = isset($arguments['include_container'])
241+
$arguments['include_container'] = isset($arguments['include_container'])
241242
? $arguments['include_container']
242243
: true;
243244
$arguments['display_minimal_price'] = isset($arguments['display_minimal_price'])
@@ -261,7 +262,6 @@ public function getProductPriceHtml(
261262
);
262263
}
263264

264-
265265
/**
266266
* @return bool
267267
*/

Block/OnSaleProduct.php

+9-11
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class OnSaleProduct extends AbstractSlider
4242

4343
/**
4444
* OnSaleProduct constructor.
45+
*
4546
* @param Context $context
4647
* @param CollectionFactory $productCollectionFactory
4748
* @param Visibility $catalogProductVisibility
@@ -60,8 +61,7 @@ public function __construct(
6061
HttpContext $httpContext,
6162
EncoderInterface $urlEncoder,
6263
array $data = []
63-
)
64-
{
64+
) {
6565
$this->_dateTimeStore = $dateTime;
6666
parent::__construct(
6767
$context,
@@ -80,15 +80,15 @@ public function __construct(
8080
*/
8181
public function getProductCollection()
8282
{
83-
$date = strtotime($this->_dateTimeStore->gmtDate());
84-
$collection = $this->_productCollectionFactory->create()->addAttributeToSelect('*');
83+
$date = strtotime($this->_dateTimeStore->gmtDate());
84+
$collection = $this->_productCollectionFactory->create()->addAttributeToSelect('*');
8585
$productIds = [];
8686

8787
foreach ($collection as $product) {
8888
if ($product->getTypeId() === 'configurable' && $product->getVisibility() != 1) {
8989
$_children = $product->getTypeInstance()->getUsedProducts($product);
90-
foreach ($_children as $child){
91-
$specialPrice = (float)$child->getSpecialPrice();
90+
foreach ($_children as $child) {
91+
$specialPrice = (float) $child->getSpecialPrice();
9292
if ($specialPrice) {
9393
if ($specialPrice < ((float) $child->getPrice())) {
9494
$fromDate = strtotime($child->getSpecialFromDate());
@@ -97,17 +97,16 @@ public function getProductCollection()
9797
if ($toDate > $date) {
9898
$productIds[] = $product->getId();
9999
}
100-
}else {
100+
} else {
101101
if ($fromDate < $date) {
102102
$productIds[] = $product->getId();
103103
}
104104
}
105105
}
106106
}
107107
}
108-
109108
} elseif ($product->getTypeId() === 'simple' && $product->getVisibility() != 1) {
110-
$specialPriceSp = (float)$product->getData('special_price');
109+
$specialPriceSp = (float) $product->getData('special_price');
111110
if ($specialPriceSp) {
112111
if ($specialPriceSp < ((float) $product->getPrice())) {
113112
$fromDateSp = strtotime($product->getSpecialFromDate());
@@ -116,7 +115,7 @@ public function getProductCollection()
116115
if ($toDateSp > $date) {
117116
$productIds[] = $product->getId();
118117
}
119-
}else {
118+
} else {
120119
if ($fromDateSp < $date) {
121120
$productIds[] = $product->getId();
122121
}
@@ -133,7 +132,6 @@ public function getProductCollection()
133132
->addAttributeToSelect('*')
134133
->addStoreFilter($this->getStoreId())->setPageSize($this->getProductsCount());
135134

136-
137135
return $collectionClone;
138136
}
139137
}

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"mageplaza/module-core": "^1.4.5"
66
},
77
"type": "magento2-module",
8-
"version": "2.0.7",
8+
"version": "2.0.8",
99
"license": "proprietary",
1010
"authors": [
1111
{

view/frontend/templates/productslider.phtml

+11-11
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ $type = 'widget-product-grid';
2828
$title = $block->getTitle();
2929
$blockId = $block->getSliderId() . uniqid('-', false);
3030
$items = $block->getProductCollection();
31-
if ($items && $items->getSize()) : ?>
31+
if ($items && $items->getSize()): ?>
3232
<div class="mp-product-slider-block block widget block-products-list <?= /** @noEscape */ $mode ?>">
3333
<h2 class="mp-product-slider-title"><?= $block->escapeHtml($title) ?></h2>
3434
<p class="mp-ps-info"><?= $block->escapeHtml($block->getDescription()) ?></p>
@@ -38,7 +38,7 @@ if ($items && $items->getSize()) : ?>
3838
<ol class="product-items widget-viewed-grid">
3939
<?php $iterator = 1; ?>
4040
<div id="mp-list-items-<?= /** @noEscape */ $blockId ?>" class="owl-carousel owl-theme">
41-
<?php foreach ($items as $_item) : ?>
41+
<?php foreach ($items as $_item): ?>
4242
<?= ($iterator++ == 1) ? '<li class="product-item product-slider"">' : '</li><li class="product-item product-slider"">' ?>
4343
<div class="slider-product-item-info">
4444
<a href="<?= $block->escapeUrl($block->getProductUrl($_item)) ?>"
@@ -53,20 +53,20 @@ if ($items && $items->getSize()) : ?>
5353
</a>
5454
</strong>
5555

56-
<?php if ($block->canShowReview()) : ?>
56+
<?php if ($block->canShowReview()): ?>
5757
<?= $block->getReviewsSummaryHtml($_item, 'short', true) ?>
5858
<?php endif; ?>
5959

6060
<?= /** @noEscape */ $block->getProductDetailsHtml($_item) ?>
6161

62-
<?php if ($block->canShowPrice()) : ?>
62+
<?php if ($block->canShowPrice()): ?>
6363
<?= /** @noEscape */ $block->getProductPriceHtml($_item, $type) ?>
6464
<?php endif; ?>
6565

6666
<div class="product actions slider-product-item-actions product-item-actions">
67-
<?php if ($block->canShowAddToCart()) : ?>
67+
<?php if ($block->canShowAddToCart()): ?>
6868
<div class="actions-primary">
69-
<?php if ($_item->isSaleable()) : ?>
69+
<?php if ($_item->isSaleable()): ?>
7070
<?php $postParams = $block->getAddToCartPostParams($_item); ?>
7171
<form data-role="tocart-form" data-product-sku="<?= $block->escapeHtml($_item->getSku()) ?>" action="<?= /* @NoEscape */ $postParams['action'] ?>" method="post">
7272
<input type="hidden" name="product" value="<?= /* @escapeNotVerified */ $postParams['data']['product'] ?>">
@@ -78,25 +78,25 @@ if ($items && $items->getSize()) : ?>
7878
<span><?= /** @noEscape */ __('Add to Cart') ?></span>
7979
</button>
8080
</form>
81-
<?php else : ?>
82-
<?php if ($_item->getIsSalable()) : ?>
81+
<?php else: ?>
82+
<?php if ($_item->getIsSalable()): ?>
8383
<div class="stock available"><span><?= $block->escapeHtml(__('In stock')) ?></span></div>
84-
<?php else : ?>
84+
<?php else: ?>
8585
<div class="stock unavailable"><span><?= $block->escapeHtml(__('Out of stock')) ?></span></div>
8686
<?php endif; ?>
8787
<?php endif; ?>
8888
</div>
8989
<div class="secondary-addto-links actions-secondary"
9090
data-role="add-to-links">
91-
<?php if ($this->helper('Magento\Wishlist\Helper\Data')->isAllow()) : ?>
91+
<?php if ($this->helper('Magento\Wishlist\Helper\Data')->isAllow()): ?>
9292
<a href="#"
9393
data-post='<?= /** @noEscape */ $block->getAddToWishlistParams($_item); ?>'
9494
class="action towishlist" data-action="add-to-wishlist"
9595
title="<?= /** @noEscape */ __('Add to Wish List') ?>">
9696
<span><?= /** @noEscape */ __('Add to Wish List') ?></span>
9797
</a>
9898
<?php endif; ?>
99-
<?php if ($block->getAddToCompareUrl()) : ?>
99+
<?php if ($block->getAddToCompareUrl()): ?>
100100
<?php $compareHelper = $this->helper('Magento\Catalog\Helper\Product\Compare'); ?>
101101
<a href="#" class="action tocompare"
102102
data-post='<?= /** @noEscape */ $compareHelper->getPostDataParams($_item); ?>'

0 commit comments

Comments
 (0)