Skip to content

Commit e170130

Browse files
authored
Merge pull request #77 from mageplaza/develop23
Develop23
2 parents a778094 + 4435732 commit e170130

11 files changed

+290
-64
lines changed

.github/ISSUE_TEMPLATE.md

-25
This file was deleted.

.github/ISSUE_TEMPLATE/bug_report.md

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +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.
Original file line numberDiff line numberDiff line change
@@ -0,0 +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. -->
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +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? -->

.github/PULL_REQUEST_TEMPLATE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
### Fixed Issues (if relevant)
77
<!--- Provide a list of fixed issues in the format magento/magento2#<issue_number>, if relevant -->
8-
1. https://github.com/mageplaza/magento-2-product-slider/<issue_number>: Issue title
8+
1. https://github.com/mageplaza/magento-2-reports/<issue_number>: Issue title
99
2. ...
1010

1111
### Manual testing scenarios

.github/no-response.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ closeComment: >
1010
to our request for more information from the original author. With only the
1111
information that is currently in the issue, we don't have enough information
1212
to take action. Please reach out if you have or find the answers we need so
13-
that we can investigate further.
13+
that we can investigate further.

Block/AbstractSlider.php

+100-2
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,29 @@
2727
use Magento\Catalog\Model\Product;
2828
use Magento\Catalog\Model\Product\Visibility;
2929
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
30+
use Magento\Catalog\Pricing\Price\FinalPrice;
3031
use Magento\Framework\App\ActionInterface;
3132
use Magento\Framework\App\Http\Context as HttpContext;
33+
use Magento\Framework\App\ObjectManager;
34+
use Magento\Framework\DataObject\IdentityInterface;
35+
use Magento\Framework\Exception\LocalizedException;
3236
use Magento\Framework\Exception\NoSuchEntityException;
37+
use Magento\Framework\Pricing\PriceCurrencyInterface;
38+
use Magento\Framework\Pricing\Render;
3339
use Magento\Framework\Stdlib\DateTime\DateTime;
3440
use Magento\Framework\Url\EncoderInterface;
41+
use Magento\Widget\Block\BlockInterface;
3542
use Mageplaza\Productslider\Helper\Data;
3643
use Mageplaza\Productslider\Model\Config\Source\Additional;
3744

3845
/**
3946
* Class AbstractSlider
4047
* @package Mageplaza\Productslider\Block
4148
*/
42-
abstract class AbstractSlider extends AbstractProduct
49+
abstract class AbstractSlider extends AbstractProduct implements BlockInterface, IdentityInterface
4350
{
51+
private $priceCurrency;
52+
4453
/**
4554
* @var DateTime
4655
*/
@@ -133,6 +142,7 @@ public function getCacheKeyInfo()
133142
{
134143
return [
135144
'MAGEPLAZA_PRODUCT_SLIDER',
145+
$this->getPriceCurrency()->getCurrency()->getCode(),
136146
$this->_storeManager->getStore()->getId(),
137147
$this->httpContext->getValue(\Magento\Customer\Model\Context::CONTEXT_GROUP),
138148
$this->getSliderId()
@@ -157,6 +167,18 @@ public function getDisplayAdditional()
157167
return $display;
158168
}
159169

170+
/**
171+
* @return mixed
172+
*/
173+
private function getPriceCurrency()
174+
{
175+
if ($this->priceCurrency === null) {
176+
$this->priceCurrency = ObjectManager::getInstance()
177+
->get(PriceCurrencyInterface::class);
178+
}
179+
return $this->priceCurrency;
180+
}
181+
160182
/**
161183
* Get post parameters.
162184
*
@@ -185,6 +207,61 @@ public function canShowPrice()
185207
return in_array(Additional::SHOW_PRICE, $this->getDisplayAdditional(), true);
186208
}
187209

210+
/**
211+
* @return bool|\Magento\Framework\View\Element\BlockInterface
212+
* @throws LocalizedException
213+
*/
214+
protected function getPriceRender()
215+
{
216+
return $this->getLayout()->getBlock('product.price.render.default');
217+
}
218+
219+
/**
220+
* @param Product $product
221+
* @param null $priceType
222+
* @param string $renderZone
223+
* @param array $arguments
224+
*
225+
* @return string
226+
* @throws LocalizedException
227+
*/
228+
public function getProductPriceHtml(
229+
Product $product,
230+
$priceType = null,
231+
$renderZone = Render::ZONE_ITEM_LIST,
232+
array $arguments = []
233+
) {
234+
if (!isset($arguments['zone'])) {
235+
$arguments['zone'] = $renderZone;
236+
}
237+
$arguments['price_id'] = isset($arguments['price_id'])
238+
? $arguments['price_id']
239+
: 'old-price-' . $product->getId() . '-' . $priceType;
240+
$arguments['include_container'] = isset($arguments['include_container'])
241+
? $arguments['include_container']
242+
: true;
243+
$arguments['display_minimal_price'] = isset($arguments['display_minimal_price'])
244+
? $arguments['display_minimal_price']
245+
: true;
246+
247+
/** @var Render $priceRender */
248+
$priceRender = $this->getLayout()->getBlock('product.price.render.default');
249+
if (!$priceRender) {
250+
$priceRender = $this->getLayout()->createBlock(
251+
Render::class,
252+
'product.price.render.default',
253+
['data' => ['price_render_handle' => 'catalog_product_prices']]
254+
);
255+
}
256+
257+
return $priceRender->render(
258+
FinalPrice::PRICE_CODE,
259+
$product,
260+
$arguments
261+
);
262+
}
263+
264+
188265
/**
189266
* @return bool
190267
*/
@@ -295,9 +372,13 @@ public function getResponsiveConfig()
295372
$responsiveConfig = [];
296373
}
297374

375+
if (empty($responsiveConfig)) {
376+
return '';
377+
}
378+
298379
$responsiveOptions = '';
299380
foreach ($responsiveConfig as $config) {
300-
if ($config['size'] && $config['items']) {
381+
if (!empty($config['size']) && !empty($config['items'])) {
301382
$responsiveOptions .= $config['size'] . ':{items:' . $config['items'] . '},';
302383
}
303384
}
@@ -339,6 +420,23 @@ public function getStoreId()
339420
return $this->_storeManager->getStore()->getId();
340421
}
341422

423+
/**
424+
* @return array|string[]
425+
*/
426+
public function getIdentities()
427+
{
428+
$identities = [];
429+
if ($this->getProductCollection()) {
430+
foreach ($this->getProductCollection() as $product) {
431+
if ($product instanceof IdentityInterface) {
432+
$identities += $product->getIdentities();
433+
}
434+
}
435+
}
436+
437+
return $identities ?: [Product::CACHE_TAG];
438+
}
439+
342440
/**
343441
* Get Product Count is displayed
344442
*

0 commit comments

Comments
 (0)