Skip to content

Commit

Permalink
Merge pull request #77 from mageplaza/develop23
Browse files Browse the repository at this point in the history
Develop23
  • Loading branch information
haitv282 authored Oct 13, 2020
2 parents a778094 + 4435732 commit e170130
Show file tree
Hide file tree
Showing 11 changed files with 290 additions and 64 deletions.
25 changes: 0 additions & 25 deletions .github/ISSUE_TEMPLATE.md

This file was deleted.

34 changes: 34 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
name: Bug report
about: Technical issue with the extension
labels: 'Issue'

---

<!---
Fields marked with (*) are required. Please don't remove the template.
-->

### Preconditions (*)
<!---
Provide the exact Magento version (example: 2.4.0) and any important information on the environment where bug is reproducible.
-->
1.
2.

### Steps to reproduce (*)
<!---
Important: Provide a set of clear steps to reproduce this bug. We can not provide support without clear instructions on how to reproduce.
-->
1.
2.

### Expected result (*)
<!--- Tell us what do you expect to happen. -->
1. [Screenshots, logs or description]
2.

### Actual result (*)
<!--- Tell us what happened instead. Include error messages and issues. -->
1. [Screenshots, logs or description]
2.
19 changes: 19 additions & 0 deletions .github/ISSUE_TEMPLATE/developer-experience-issue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
name: Developer experience issue
about: Issues related to customization, extensibility, modularity
labels: 'Experience'

---

<!---
Fields marked with (*) are required. Please don't remove the template.
-->

### Summary (*)
<!--- Describe the issue you are experiencing. Include general information, error messages, environments, and so on. -->

### Examples (*)
<!--- Provide code examples or a patch with a test (recommended) to clearly indicate the problem. -->

### Proposed solution
<!--- Suggest your potential solutions for this issue. -->
22 changes: 22 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
name: Feature request
about: Request feature for development
labels: 'Feature Request'

---

<!---
Fields marked with (*) are required. Please don't remove the template.
-->

### Description (*)
<!--- Describe the feature you would like to add. -->

### Expected behavior (*)
<!--- What is the expected behavior of this feature? How is it going to work? -->

### Benefits
<!--- How do you think this feature would improve the extension? -->

### Additional information
<!--- What other information can you provide about the desired feature? -->
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

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

### Manual testing scenarios
Expand Down
2 changes: 1 addition & 1 deletion .github/no-response.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ closeComment: >
to our request for more information from the original author. With only the
information that is currently in the issue, we don't have enough information
to take action. Please reach out if you have or find the answers we need so
that we can investigate further.
that we can investigate further.
102 changes: 100 additions & 2 deletions Block/AbstractSlider.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,29 @@
use Magento\Catalog\Model\Product;
use Magento\Catalog\Model\Product\Visibility;
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
use Magento\Catalog\Pricing\Price\FinalPrice;
use Magento\Framework\App\ActionInterface;
use Magento\Framework\App\Http\Context as HttpContext;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\DataObject\IdentityInterface;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Pricing\PriceCurrencyInterface;
use Magento\Framework\Pricing\Render;
use Magento\Framework\Stdlib\DateTime\DateTime;
use Magento\Framework\Url\EncoderInterface;
use Magento\Widget\Block\BlockInterface;
use Mageplaza\Productslider\Helper\Data;
use Mageplaza\Productslider\Model\Config\Source\Additional;

/**
* Class AbstractSlider
* @package Mageplaza\Productslider\Block
*/
abstract class AbstractSlider extends AbstractProduct
abstract class AbstractSlider extends AbstractProduct implements BlockInterface, IdentityInterface
{
private $priceCurrency;

/**
* @var DateTime
*/
Expand Down Expand Up @@ -133,6 +142,7 @@ public function getCacheKeyInfo()
{
return [
'MAGEPLAZA_PRODUCT_SLIDER',
$this->getPriceCurrency()->getCurrency()->getCode(),
$this->_storeManager->getStore()->getId(),
$this->httpContext->getValue(\Magento\Customer\Model\Context::CONTEXT_GROUP),
$this->getSliderId()
Expand All @@ -157,6 +167,18 @@ public function getDisplayAdditional()
return $display;
}

/**
* @return mixed
*/
private function getPriceCurrency()
{
if ($this->priceCurrency === null) {
$this->priceCurrency = ObjectManager::getInstance()
->get(PriceCurrencyInterface::class);
}
return $this->priceCurrency;
}

/**
* Get post parameters.
*
Expand Down Expand Up @@ -185,6 +207,61 @@ public function canShowPrice()
return in_array(Additional::SHOW_PRICE, $this->getDisplayAdditional(), true);
}

/**
* @return bool|\Magento\Framework\View\Element\BlockInterface
* @throws LocalizedException
*/
protected function getPriceRender()
{
return $this->getLayout()->getBlock('product.price.render.default');
}

/**
* @param Product $product
* @param null $priceType
* @param string $renderZone
* @param array $arguments
*
* @return string
* @throws LocalizedException
*/
public function getProductPriceHtml(
Product $product,
$priceType = null,
$renderZone = Render::ZONE_ITEM_LIST,
array $arguments = []
) {
if (!isset($arguments['zone'])) {
$arguments['zone'] = $renderZone;
}
$arguments['price_id'] = isset($arguments['price_id'])
? $arguments['price_id']
: 'old-price-' . $product->getId() . '-' . $priceType;
$arguments['include_container'] = isset($arguments['include_container'])
? $arguments['include_container']
: true;
$arguments['display_minimal_price'] = isset($arguments['display_minimal_price'])
? $arguments['display_minimal_price']
: true;

/** @var Render $priceRender */
$priceRender = $this->getLayout()->getBlock('product.price.render.default');
if (!$priceRender) {
$priceRender = $this->getLayout()->createBlock(
Render::class,
'product.price.render.default',
['data' => ['price_render_handle' => 'catalog_product_prices']]
);
}

return $priceRender->render(
FinalPrice::PRICE_CODE,
$product,
$arguments
);
}


/**
* @return bool
*/
Expand Down Expand Up @@ -295,9 +372,13 @@ public function getResponsiveConfig()
$responsiveConfig = [];
}

if (empty($responsiveConfig)) {
return '';
}

$responsiveOptions = '';
foreach ($responsiveConfig as $config) {
if ($config['size'] && $config['items']) {
if (!empty($config['size']) && !empty($config['items'])) {
$responsiveOptions .= $config['size'] . ':{items:' . $config['items'] . '},';
}
}
Expand Down Expand Up @@ -339,6 +420,23 @@ public function getStoreId()
return $this->_storeManager->getStore()->getId();
}

/**
* @return array|string[]
*/
public function getIdentities()
{
$identities = [];
if ($this->getProductCollection()) {
foreach ($this->getProductCollection() as $product) {
if ($product instanceof IdentityInterface) {
$identities += $product->getIdentities();
}
}
}

return $identities ?: [Product::CACHE_TAG];
}

/**
* Get Product Count is displayed
*
Expand Down
Loading

0 comments on commit e170130

Please sign in to comment.