Commit f2fead8d by lmf

去除多余插件

优化minicat
parent 60f10faa
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="JTool_CheckoutSideBal" setup_version="1.0.0"/>
</config>
\ No newline at end of file
<?php
\Magento\Framework\Component\ComponentRegistrar::register(\Magento\Framework\Component\ComponentRegistrar::MODULE,
'JTool_CheckoutSideBal',
__DIR__
);
\ No newline at end of file
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="checkout.root">
<arguments>
<argument name="jsLayout" xsi:type="array">
<item name="components" xsi:type="array">
<item name="checkout" xsi:type="array">
<item name="children" xsi:type="array">
<item name="sidebar" xsi:type="array">
<item name="children" xsi:type="array">
<item name="summary" xsi:type="array">
<item name="children" xsi:type="array">
<item name="discount" xsi:type="array">
<item name="component" xsi:type="string">Magento_SalesRule/js/view/payment/discount</item>
<item name="children" xsi:type="array">
<item name="errors" xsi:type="array">
<item name="sortOrder" xsi:type="string">0</item>
<item name="component" xsi:type="string">Magento_SalesRule/js/view/payment/discount-messages</item>
<item name="displayArea" xsi:type="string">messages</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</argument>
</arguments>
</referenceBlock>
</body>
</page>
\ No newline at end of file
<?php
/**
* Developer: Hemant Kumar Singh Magento Developer
* Website: http://www.wishusucess.com/
*/
namespace JTool\CustomClass\Model\Plugin;
class AttributeMergerPlugin
{
public function afterMerge(\Magento\Checkout\Block\Checkout\AttributeMerger $subject, $result)
{
if (array_key_exists('telephone', $result)) {
$result['telephone']['additionalClasses'] = 'teliphone_number';
}
return $result;
}
}
\ No newline at end of file
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../vendor/magento/framework/ObjectManager/etc/config.xsd">
<type name="\Magento\Checkout\Block\Checkout\AttributeMerger">
<plugin name="customAttributeMerger" type="\JTool\CustomClass\Model\Plugin\AttributeMergerPlugin"/>
</type>
</config>
\ No newline at end of file
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="JTool_CustomClass" setup_version="1.0.0" active="true"></module>
</config>
\ No newline at end of file
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'JTool_CustomClass',
__DIR__
);
\ No newline at end of file
<?php
namespace JTool\LimitRelatedCrossUpsell\Block\Cart;
class Crosssell extends \Magento\Checkout\Block\Cart\Crosssell
{
/**
* We can now set our limit here
*/
const CROSSSELL_LIMIT = 20;
/**
* Crosssell constructor.
* @param \Magento\Catalog\Block\Product\Context $context
* @param \Magento\Checkout\Model\Session $checkoutSession
* @param \Magento\Catalog\Model\Product\Visibility $productVisibility
* @param \Magento\Catalog\Model\Product\LinkFactory $productLinkFactory
* @param \Magento\Quote\Model\Quote\Item\RelatedProducts $itemRelationsList
* @param \Magento\CatalogInventory\Helper\Stock $stockHelper
* @param array $data
*/
public function __construct(
\Magento\Catalog\Block\Product\Context $context,
\Magento\Checkout\Model\Session $checkoutSession,
\Magento\Catalog\Model\Product\Visibility $productVisibility,
\Magento\Catalog\Model\Product\LinkFactory $productLinkFactory,
\Magento\Quote\Model\Quote\Item\RelatedProducts $itemRelationsList,
\Magento\CatalogInventory\Helper\Stock $stockHelper,
array $data = []
) {
parent::__construct(
$context,
$checkoutSession,
$productVisibility,
$productLinkFactory,
$itemRelationsList,
$stockHelper,
$data
);
$this->_maxItemCount = self::CROSSSELL_LIMIT; //limit number of products
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Magento\Checkout\Block\Cart\Crosssell" type="JTool\LimitRelatedCrossUpsell\Block\Cart\Crosssell" ></preference>
</config>
\ No newline at end of file
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="JTool_LimitRelatedCrossUpsell" setup_version="1.0.0">
<sequence>
<module name="Magento_Checkout"></module>
<module name="Magento_Catalog"></module>
</sequence>
</module>
</config>
\ No newline at end of file
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'JTool_LimitRelatedCrossUpsell',
__DIR__
);
\ No newline at end of file
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="JTool_PlaceOrder" setup_version="1.0.0"/>
</config>
\ No newline at end of file
<?php
\Magento\Framework\Component\ComponentRegistrar::register(\Magento\Framework\Component\ComponentRegistrar::MODULE,
'JTool_PlaceOrder',
__DIR__
);
\ No newline at end of file
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="checkout" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<css src="JTool_PlaceOrder::css/place_order_button.css"/>
</head>
<body>
<referenceBlock name="checkout.root">
<arguments>
<argument name="jsLayout" xsi:type="array">
<item name="components" xsi:type="array">
<item name="checkout" xsi:type="array">
<item name="children" xsi:type="array">
<item name="sidebar" xsi:type="array">
<item name="children" xsi:type="array">
<item name="summary" xsi:type="array">
<item name="component" xsi:type="string">JTool_PlaceOrder/js/view/summary</item>
<item name="config" xsi:type="array">
<item name="template" xsi:type="string">JTool_PlaceOrder/summary</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</argument>
</arguments>
</referenceBlock>
</body>
</page>
\ No newline at end of file
@media(min-width: 640px) {
.payment-method-content .actions-toolbar {
display: none;
}
}
@media (max-width: 639.98px) {
.opc-summary-wrapper .actions-toolbar-trigger{
display: none;
}
}
\ No newline at end of file
define(
[
'jquery',
'ko',
'Magento_Checkout/js/view/summary',
'Magento_Checkout/js/model/step-navigator',
],
function(
$,
ko,
Component,
stepNavigator
) {
'use strict';
return Component.extend({
isVisible: function () {
return stepNavigator.isProcessed('shipping');
},
initialize: function () {
$(function() {
$('body').on("click", '#place-order-trigger', function () {
$(".payment-method._active").find('.action.primary.checkout').trigger( 'click' );
});
});
var self = this;
this._super();
}
});
}
);
\ No newline at end of file
<div class="opc-block-summary" data-bind="blockLoader: isLoading">
<span data-bind="i18n: 'Order Summary'" class="title"></span>
<!-- ko foreach: elems() -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!-- /ko -->
</div>
<!-- ko if: (isVisible()) -->
<div class="actions-toolbar-trigger" id="place-order-trigger-wrapper">
<button type="button" class="button action primary" id="place-order-trigger" value="Place Order" >
<span>Place Order</span>
</button>
</div>
<!-- /ko -->
\ No newline at end of file
<?php
namespace JTool\toolbar\Plugin\Catalog\Block;
class Toolbar
{
public function aroundSetCollection(\Magento\Catalog\Block\Product\ProductList\Toolbar $subject,
\Closure $proceed, $collection)
{
//ordered_qty
$currentOrder = $subject->getCurrentOrder();
$this->_collection = $collection;
$result = $proceed($collection);
if($currentOrder)
{
if($currentOrder == 'high_to_low')
{
$subject->getCollection()->setOrder('price', 'desc');
}
elseif ($currentOrder == 'low_to_high')
{
$subject->getCollection()->setOrder('price', 'asc');
}
elseif ($currentOrder == 'new_arrivals')
{
$this->_collection->getSelect()->order('e.created_at DESC');
}
elseif ($currentOrder == 'best_seller')
{
$subject->getCollection()->getSelect()->joinLeft(
'sales_order_item',
'e.entity_id = sales_order_item.product_id',
array('qty_ordered'=>'(select sum(soi.qty_ordered) from sales_order_item soi where soi.product_id = e.entity_id)'))->distinct(true)
->order('qty_ordered desc');
}
}
return $result;
}
}
\ No newline at end of file
<?php
namespace JTool\toolbar\Plugin\Catalog\Model;
class Config
{
public function afterGetAttributeUsedForSortByArray(\Magento\Catalog\Model\Config $catalogConfig, $options)
{
$options['best_seller'] = __('Best Seller');
$options['new_arrivals'] = __('New Arrivals');
$options['low_to_high'] = __('Price Low To High');
$options['high_to_low'] = __('Price High To Low');
$options['position'] = __('Recommend');
unset($options['name']);
unset($options['price']);
return $options;
}
}
\ No newline at end of file
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Catalog\Block\Product\ProductList\Toolbar">
<plugin name="custom_custom_block_toolbar" type="JTool\toolbar\Plugin\Catalog\Block\Toolbar"/>
</type>
<type name="Magento\Catalog\Model\Config">
<plugin name="custom_catalog_model_config" type="JTool\toolbar\Plugin\Catalog\Model\Config"/>
</type>
</config>
\ No newline at end of file
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="JTool_toolbar" setup_version="1.0.0"/>
</config>
\ No newline at end of file
<?php
\Magento\Framework\Component\ComponentRegistrar::register(\Magento\Framework\Component\ComponentRegistrar::MODULE,
'JTool_toolbar',
__DIR__
);
\ No newline at end of file
<?php
/**
* NOTICE OF LICENSE
* You may not sell, distribute, sub-license, rent, lease or lend complete or portion of software to anyone.
*
* DISCLAIMER
* Do not edit or add to this file if you wish to upgrade to newer
* versions in the future.
*
* @package RLTSquare_ProductReviewImages
* @copyright Copyright (c) 2022 RLTSquare (https://www.rltsquare.com)
* @contacts support@rltsquare.com
* @license See the LICENSE.md file in module root directory
*/
namespace RLTSquare\ProductReviewImages\Block\Adminhtml\Edit;
use Magento\Backend\Block\Template\Context;
use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Catalog\Model\ProductFactory;
use Magento\Customer\Api\CustomerRepositoryInterface;
use Magento\Framework\Data\FormFactory;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Registry;
use Magento\Review\Helper\Data;
use Magento\Store\Model\System\Store;
use Magento\Framework\Escaper;
/**
* Class Form
*
* @package RLTSquare\ProductReviewImages\Block\Adminhtml\Edit
* @author Umar Chaudhry <umarch@rltsquare.com>
*/
class Form extends \Magento\Review\Block\Adminhtml\Edit\Form
{
/**
* Review data
*
* @var Data
*/
protected Data $reviewData;
/**
* @var CustomerRepositoryInterface
*/
protected $customerRepository;
/**
* Catalog product factory
*
* @var ProductFactory
*/
protected ProductFactory $productFactory;
/**
* Catalog product factory
*
* @var ProductRepositoryInterface
*/
protected ProductRepositoryInterface $productRepository;
/**
* Core system store model
*
* @var Store
*/
protected Store $systemStore;
/**
*
* @var Escaper $escaper
*/
protected Escaper $escape;
/**
* @param Context $context
* @param Registry $registry
* @param FormFactory $formFactory
* @param Store $systemStore
* @param CustomerRepositoryInterface $customerRepository
* @param ProductFactory $productFactory
* @param Data $reviewData
* @param ProductRepositoryInterface $productRepository
* @param Escaper $escape
* @param array $data
*/
public function __construct(
Context $context,
Registry $registry,
FormFactory $formFactory,
Store $systemStore,
CustomerRepositoryInterface $customerRepository,
ProductFactory $productFactory,
Data $reviewData,
ProductRepositoryInterface $productRepository,
Escaper $escape,
array $data = []
) {
$this->reviewData = $reviewData;
$this->customerRepository = $customerRepository;
$this->productFactory = $productFactory;
$this->systemStore = $systemStore;
$this->productRepository = $productRepository;
$this->escape = $escape;
parent::__construct($context, $registry, $formFactory,$systemStore,$customerRepository, $productFactory,$reviewData,$data);
}
/**
* override,
* add custom fieldsets in form
*
* @return $this
* @throws LocalizedException
*/
protected function _prepareForm(): Form
{
$review = $this->_coreRegistry->registry('review_data');
$product = $this->productRepository->getById($review->getEntityPkValue());
$form = $this->_formFactory->create(
[
'data' => [
'id' => 'edit_form',
'action' => $this->getUrl(
'review/*/save',
[
'id' => $this->getRequest()->getParam('id'),
'ret' => $this->_coreRegistry->registry('ret')
]
),
'method' => 'post'
],
]
);
$fieldset = $form->addFieldset(
'review_details',
['legend' => __('Review Details'), 'class' => 'fieldset-wide']
);
$fieldset->addField(
'product_name',
'note',
[
'label' => __('Product'),
'text' => '<a href="' . $this->getUrl(
'catalog/product/edit',
['id' => $product->getId()]
) . '" onclick="this.target=\'blank\'">' . $this->escapeHtml(
$product->getName()
) . '</a>'
]
);
try {
$customer = $this->customerRepository->getById($review->getCustomerId());
$customerText = __(
'<a href="%1" onclick="this.target=\'blank\'">%2 %3</a> <a href="mailto:%4">(%4)</a>',
$this->getUrl('customer/index/edit', ['id' => $customer->getId(), 'active_tab' => 'review']),
$this->escape->escapeHtml($customer->getFirstname()),
$this->escape->escapeHtml($customer->getLastname()),
$this->escape->escapeHtml($customer->getEmail())
);
} catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
$customerText = ($review->getStoreId() == \Magento\Store\Model\Store::DEFAULT_STORE_ID)
? __('Administrator') : __('Guest');
}
$fieldset->addField('customer', 'note', ['label' => __('Author'), 'text' => $customerText]);
$fieldset->addField(
'summary-rating',
'note',
[
'label' => __('Summary Rating'),
'text' => $this->getLayout()->createBlock(
\Magento\Review\Block\Adminhtml\Rating\Summary::class
)->toHtml()
]
);
$fieldset->addField(
'detailed-rating',
'note',
[
'label' => __('Detailed Rating'),
'required' => true,
'text' => '<div id="rating_detail">' . $this->getLayout()->createBlock(
\Magento\Review\Block\Adminhtml\Rating\Detailed::class
)->toHtml() . '</div>'
]
);
$fieldset->addField(
'status_id',
'select',
[
'label' => __('Status'),
'required' => true,
'name' => 'status_id',
'values' => $this->_reviewData->getReviewStatusesOptionArray()
]
);
/**
* Check is single store mode
*/
if (!$this->_storeManager->hasSingleStore()) {
$field = $fieldset->addField(
'select_stores',
'multiselect',
[
'label' => __('Visibility'),
'required' => true,
'name' => 'stores[]',
'values' => $this->systemStore->getStoreValuesForForm()
]
);
$renderer = $this->getLayout()->createBlock(
\Magento\Backend\Block\Store\Switcher\Form\Renderer\Fieldset\Element::class
);
$field->setRenderer($renderer);
$review->setSelectStores($review->getStores());
} else {
$fieldset->addField(
'select_stores',
'hidden',
['name' => 'stores[]', 'value' => $this->_storeManager->getStore(true)->getId()]
);
$review->setSelectStores($this->_storeManager->getStore(true)->getId());
}
$fieldset->addField(
'nickname',
'text',
['label' => __('Nickname'), 'required' => true, 'name' => 'nickname']
);
$fieldset->addField(
'title',
'text',
['label' => __('Summary of Review'), 'required' => true, 'name' => 'title']
);
$fieldset->addField(
'detail',
'textarea',
['label' => __('Review'), 'required' => true, 'name' => 'detail', 'style' => 'height:24em;']
);
$fieldset->addField(
'review-media',
'note',
[
'label' => __('Review Media'),
'text' => $this->getLayout()->createBlock(
\RLTSquare\ProductReviewImages\Block\Adminhtml\Edit\Media::class
)->toHtml()
]
);
$fieldset->addField(
'deleted_media',
'text',
[
'name' => 'deleted_media',
'style' => 'visibility:hidden;'
]
);
$form->setUseContainer(true);
$form->setValues($review->getData());
$this->setForm($form);
return \Magento\Backend\Block\Widget\Form::_prepareForm();
}
}
<?php
/**
* NOTICE OF LICENSE
* You may not sell, distribute, sub-license, rent, lease or lend complete or portion of software to anyone.
*
* DISCLAIMER
* Do not edit or add to this file if you wish to upgrade to newer
* versions in the future.
*
* @package RLTSquare_ProductReviewImages
* @copyright Copyright (c) 2022 RLTSquare (https://www.rltsquare.com)
* @contacts support@rltsquare.com
* @license See the LICENSE.md file in module root directory
*/
namespace RLTSquare\ProductReviewImages\Block\Adminhtml\Edit;
use Magento\Backend\Block\Template\Context;
use Magento\Framework\Exception\NoSuchEntityException;
use RLTSquare\ProductReviewImages\Model\ResourceModel\ReviewMedia\CollectionFactory;
/**
* Class Media
*
* @package RLTSquare\ProductReviewImages\Block\Adminhtml\Edit
* @author Umar Chaudhry <umarch@rltsquare.com>
*/
class Media extends \Magento\Backend\Block\Template
{
/**
* @var CollectionFactory
*/
protected CollectionFactory $collectionFactory;
/**
* Media constructor
*
* \Magento\Backend\Block\Template\Context $context
* @param Context $context
* @param CollectionFactory $collectionFactory
*/
public function __construct(
Context $context,
CollectionFactory $collectionFactory
)
{
$this->collectionFactory = $collectionFactory;
$this->setTemplate("media.phtml");
parent::__construct($context);
}
/**
* function
* get media collection for a review
*
* @return object
*/
public function getMediaCollection(): object
{
return $this->collectionFactory->create()->addFieldToFilter('review_id', $this->getRequest()->getParam('id'));
}
/**
* function
* get review_images directory path
*
* @return string
* @throws NoSuchEntityException
*/
public function getReviewMediaUrl(): string
{
return $this->_storeManager->getStore()
->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA) . 'review_images';
}
}
<?php
/**
* NOTICE OF LICENSE
* You may not sell, distribute, sub-license, rent, lease or lend complete or portion of software to anyone.
*
* DISCLAIMER
* Do not edit or add to this file if you wish to upgrade to newer
* versions in the future.
*
* @package RLTSquare_ProductReviewImages
* @copyright Copyright (c) 2022 RLTSquare (https://www.rltsquare.com)
* @contacts support@rltsquare.com
* @license See the LICENSE.md file in module root directory
*/
namespace RLTSquare\ProductReviewImages\Block;
use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Customer\Model\Url;
use Magento\Framework\Message\ManagerInterface;
use Magento\Framework\Serialize\Serializer\Json;
use Magento\Framework\Url\EncoderInterface;
use Magento\Framework\View\Element\Template\Context;
use Magento\Review\Helper\Data;
use Magento\Review\Model\RatingFactory;
/**
* Class Form
*
* @package RLTSquare\ProductReviewImages\Block
* @author Umar Chaudhry <umarch@rltsquare.com>
*/
class Form extends \Magento\Review\Block\Form
{
/**
* Form constructor.
* @param Context $context
* @param EncoderInterface $urlEncoder
* @param Data $reviewData
* @param ProductRepositoryInterface $productRepository
* @param RatingFactory $ratingFactory
* @param ManagerInterface $messageManager
* @param \Magento\Framework\App\Http\Context $httpContext
* @param Url $customerUrl
* @param array $data
* @param Json|null $serializer
*/
public function __construct(
Context $context,
EncoderInterface $urlEncoder,
Data $reviewData,
ProductRepositoryInterface $productRepository,
RatingFactory $ratingFactory,
ManagerInterface $messageManager,
\Magento\Framework\App\Http\Context $httpContext,
Url $customerUrl,
array $data = [],
Json $serializer = null
)
{
parent::__construct($context, $urlEncoder, $reviewData, $productRepository, $ratingFactory, $messageManager, $httpContext, $customerUrl, $data, $serializer);
}
protected function _construct()
{
parent::_construct();
$this->setTemplate('RLTSquare_ProductReviewImages::form.phtml');
}
}
<?php
/**
* NOTICE OF LICENSE
* You may not sell, distribute, sub-license, rent, lease or lend complete or portion of software to anyone.
*
* DISCLAIMER
* Do not edit or add to this file if you wish to upgrade to newer
* versions in the future.
*
* @package RLTSquare_ProductReviewImages
* @copyright Copyright (c) 2022 RLTSquare (https://www.rltsquare.com)
* @contacts support@rltsquare.com
* @license See the LICENSE.md file in module root directory
*/
namespace RLTSquare\ProductReviewImages\Block\Product\View;
use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Json\EncoderInterface as JsonEncoderInterface;
use Magento\Catalog\Block\Product\Context;
use Magento\Catalog\Helper\Product;
use Magento\Catalog\Model\ProductTypes\ConfigInterface;
use Magento\Customer\Model\Session;
use Magento\Framework\Locale\FormatInterface;
use Magento\Framework\Pricing\PriceCurrencyInterface;
use Magento\Framework\Stdlib\StringUtils;
use Magento\Framework\Url\EncoderInterface;
use Magento\Review\Model\ResourceModel\Review\CollectionFactory;
/**
* Class ListView
*
* @package RLTSquare\ProductReviewImages\Block\Product\View
* @author Umar Chaudhry <umarch@rltsquare.com>
*/
class ListView extends \Magento\Review\Block\Product\View\ListView
{
/**
* ListView constructor.
* @param Context $context
* @param EncoderInterface $urlEncoder
* @param JsonEncoderInterface $jsonEncoder
* @param StringUtils $string
* @param Product $productHelper
* @param ConfigInterface $productTypeConfig
* @param FormatInterface $localeFormat
* @param Session $customerSession
* @param ProductRepositoryInterface $productRepository
* @param PriceCurrencyInterface $priceCurrency
* @param CollectionFactory $collectionFactory
* @param array $data
*/
public function __construct(
Context $context,
EncoderInterface $urlEncoder,
JsonEncoderInterface $jsonEncoder,
StringUtils $string,
Product $productHelper,
ConfigInterface $productTypeConfig,
FormatInterface $localeFormat,
Session $customerSession,
ProductRepositoryInterface $productRepository,
PriceCurrencyInterface $priceCurrency,
CollectionFactory $collectionFactory,
array $data = []
)
{
parent::__construct($context, $urlEncoder, $jsonEncoder, $string, $productHelper, $productTypeConfig, $localeFormat, $customerSession, $productRepository, $priceCurrency, $collectionFactory, $data);
}
/**
* Unused class property
* @var false
*/
protected $_forceHasOptions = false;
/**
* Get product id
*
* @return int|null
*/
public function getProductId(): ?int
{
$product = $this->getProduct();
return $product->getId();
}
/**
* Prepare product review list toolbar
*
* @return \Magento\Review\Block\Product\View\ListView
* @throws LocalizedException
*/
protected function _prepareLayout(): \Magento\Review\Block\Product\View\ListView
{
parent::_prepareLayout();
$toolbar = $this->getLayout()->getBlock('product_review_list.toolbar');
if ($toolbar) {
$toolbar->setCollection($this->getReviewsCollection());
$this->setChild('toolbar', $toolbar);
}
return $this;
}
/**
* @return \Magento\Review\Block\Product\View\ListView
*/
protected function _beforeToHtml(): \Magento\Review\Block\Product\View\ListView
{
$this->getReviewsCollection()->load()->addRateVotes();
return parent::_beforeToHtml();
}
/**
* Return review url
*
* @param int $id
* @return string
*/
public function getReviewUrl($id): string
{
return $this->getUrl('*/*/view', ['id' => $id]);
}
}
THIS LICENSE AGREEMENT IS AN AGREEMENT BETWEEN YOU (THE PERSON OR COMPANY WHO IS BEING LICENSED TO USE THE SOFTWARE OR DOCUMENTATION) AND RLTSquare.
1. By purchasing the Software you agree with the content of this Agreement
and agree to use the Software in compliance with this Agreement.
2. You are a user of this Software and RLTSquare is the owner.
3. You may not sell, resell, sub-license or lease any fragment of the Software or its Documentation to anyone.
4. If you distribute original or changed version of the Software, you must include
this Agreement without any changes and original version of the Software.
5. We do not and will not bear responsibility for any damages (including any loss of your profit or savings)
caused to you, your business and your information by use or inability to use this Software.
6. We are not liable for prosecution arising from use of the Software against law or for any illegal use.
7. In case of failure to comply with any condition of this Agreement, your license to use the Software will be revoked.
8. Agreement remains effective without any time limits until it is terminated.
9. RLTSquare reserves the right to change Agreement type for future versions of Software.
\ No newline at end of file
<?php
/**
* NOTICE OF LICENSE
* You may not sell, distribute, sub-license, rent, lease or lend complete or portion of software to anyone.
*
* DISCLAIMER
* Do not edit or add to this file if you wish to upgrade to newer
* versions in the future.
*
* @package RLTSquare_ProductReviewImages
* @copyright Copyright (c) 2022 RLTSquare (https://www.rltsquare.com)
* @contacts support@rltsquare.com
* @license See the LICENSE.md file in module root directory
*/
namespace RLTSquare\ProductReviewImages\Model\ResourceModel;
/**
* Class ReviewMedia
*
* @package RLTSquare\ProductReviewImages\Model\ResourceModel
* @author Umar Chaudhry <umarch@rltsquare.com>
*/
class ReviewMedia extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb {
/**
* constructor
*
*/
protected function _construct() {
$this->_init('rltsquare_productreviewimages_reviewmedia', 'primary_id');
}
}
<?php
/**
* NOTICE OF LICENSE
* You may not sell, distribute, sub-license, rent, lease or lend complete or portion of software to anyone.
*
* DISCLAIMER
* Do not edit or add to this file if you wish to upgrade to newer
* versions in the future.
*
* @package RLTSquare_ProductReviewImages
* @copyright Copyright (c) 2022 RLTSquare (https://www.rltsquare.com)
* @contacts support@rltsquare.com
* @license See the LICENSE.md file in module root directory
*/
namespace RLTSquare\ProductReviewImages\Model\ResourceModel\ReviewMedia;
/**
* Class Collection
*
* @package RLTSquare\ProductReviewImages\Model\ResourceModel\ReviewMedia
* @author Umar Chaudhry <umarch@rltsquare.com>
*/
class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
{
/**
* constructor
*
*/
protected function _construct()
{
$this->_init('RLTSquare\ProductReviewImages\Model\ReviewMedia','RLTSquare\ProductReviewImages\Model\ResourceModel\ReviewMedia');
}
}
<?php
/**
* NOTICE OF LICENSE
* You may not sell, distribute, sub-license, rent, lease or lend complete or portion of software to anyone.
*
* DISCLAIMER
* Do not edit or add to this file if you wish to upgrade to newer
* versions in the future.
*
* @package RLTSquare_ProductReviewImages
* @copyright Copyright (c) 2022 RLTSquare (https://www.rltsquare.com)
* @contacts support@rltsquare.com
* @license See the LICENSE.md file in module root directory
*/
namespace RLTSquare\ProductReviewImages\Model;
/**
* Class ReviewMedia
*
* @package RLTSquare\ProductReviewImages\Model
* @author Umar Chaudhry <umarch@rltsquare.com>
*/
class ReviewMedia extends \Magento\Framework\Model\AbstractModel
{
/**
* constructor
*
*/
protected function _construct()
{
$this->_init('RLTSquare\ProductReviewImages\Model\ResourceModel\ReviewMedia');
}
}
<?php
/**
* NOTICE OF LICENSE
* You may not sell, distribute, sub-license, rent, lease or lend complete or portion of software to anyone.
*
* DISCLAIMER
* Do not edit or add to this file if you wish to upgrade to newer
* versions in the future.
*
* @package RLTSquare_ProductReviewImages
* @copyright Copyright (c) 2022 RLTSquare (https://www.rltsquare.com)
* @contacts support@rltsquare.com
* @license See the LICENSE.md file in module root directory
*/
namespace RLTSquare\ProductReviewImages\Observer;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\Event\Observer;
use Magento\Framework\Exception\FileSystemException;
use Magento\Framework\Filesystem;
use Magento\Framework\Filesystem\Driver\File;
use RLTSquare\ProductReviewImages\Model\ReviewMediaFactory;
use RLTSquare\ProductReviewImages\Model\ResourceModel\ReviewMedia\CollectionFactory;
/**
* Class AdminProductReviewDeleteBefore
*
* @package RLTSquare\ProductReviewImages\Observer
* @author Umar Chaudhry <umarch@rltsquare.com>
*/
class AdminProductReviewDeleteBefore implements \Magento\Framework\Event\ObserverInterface
{
/**
* @var RequestInterface
*/
protected RequestInterface $_request;
/**
* @var ReviewMediaFactory
*/
protected ReviewMediaFactory $reviewMediaFactory;
/**
* @var DirectoryList::MEDIA
*/
protected DirectoryList $mediaDirectory;
/**
* @var File
*/
protected File $fileHandler;
/**
* @var CollectionFactory
*/
protected CollectionFactory $collectionFactory;
/**
* AdminProductReviewDeleteBefore constructor.
* @param RequestInterface $request
* @param Filesystem $filesystem
* @param File $fileHandler
* @param ReviewMediaFactory $reviewMediaFactory
* @throws FileSystemException
*/
public function __construct(
RequestInterface $request,
Filesystem $filesystem,
File $fileHandler,
ReviewMediaFactory $reviewMediaFactory
)
{
$this->_request = $request;
$this->fileHandler = $fileHandler;
$this->mediaDirectory = $filesystem->getDirectoryWrite(DirectoryList::MEDIA);
$this->reviewMediaFactory = $reviewMediaFactory;
}
/**
* function
* executes before a review is deleted
*
* @param Observer $observer
* @return void
*/
public function execute(Observer $observer): void
{
$target = $this->mediaDirectory->getAbsolutePath('review_images');
// single record deletion
$reviewId = $this->_request->getParam('id', false);
if ($reviewId) {
$this->deleteReviewMedia($reviewId);
return;
}
// mass deletion
$reviewIds = $this->_request->getParam('reviews', false);
if ($reviewIds) {
foreach ($reviewIds as $id) {
$this->deleteReviewMedia($id);
}
return;
}
}
/**
* function
* delete media against a review
*
* @param $reviewId
* @return void
*/
private function deleteReviewMedia($reviewId): void
{
$target = $this->mediaDirectory->getAbsolutePath('review_images');
try {
$thisReviewMediaCollection = $this->collectionFactory->create()->addFieldToFilter('review_id', $reviewId);
foreach ($thisReviewMediaCollection as $m) {
$path = $target . $m->getMediaUrl();
if ($this->fileHandler->isExists($path)) {
$this->fileHandler->deleteFile($path);
}
}
} catch (\Exception $e) {
$this->messageManager->addException($e, __('Something went wrong while deleting review(s) attachment(s).'));
}
}
}
<?php
/**
* NOTICE OF LICENSE
* You may not sell, distribute, sub-license, rent, lease or lend complete or portion of software to anyone.
*
* DISCLAIMER
* Do not edit or add to this file if you wish to upgrade to newer
* versions in the future.
*
* @package RLTSquare_ProductReviewImages
* @copyright Copyright (c) 2022 RLTSquare (https://www.rltsquare.com)
* @contacts support@rltsquare.com
* @license See the LICENSE.md file in module root directory
*/
namespace RLTSquare\ProductReviewImages\Observer;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\Event\Observer;
use Magento\Framework\Exception\FileSystemException;
use Magento\Framework\Filesystem;
use Magento\Framework\Filesystem\Driver\File;
use RLTSquare\ProductReviewImages\Model\ReviewMediaFactory;
use RLTSquare\ProductReviewImages\Model\ResourceModel\ReviewMedia;
/**
* Class AdminProductReviewSaveAfter
*
* @package RLTSquare\ProductReviewImages\Observer
* @author Umar Chaudhry <umarch@rltsquare.com>
*/
class AdminProductReviewSaveAfter implements \Magento\Framework\Event\ObserverInterface
{
/**
* @var RequestInterface
*/
protected RequestInterface $request;
/**
* @var ReviewMediaFactory
*/
protected ReviewMediaFactory $reviewMediaFactory;
/**
* @var DirectoryList::MEDIA
*/
protected DirectoryList $mediaDirectory;
/**
* @var File
*/
protected File $_fileHandler;
/**
* @var ReviewMedia
*/
protected ReviewMedia $reviewMediaResourceModel;
/**
* AdminProductReviewSaveAfter constructor.
* @param RequestInterface $request
* @param Filesystem $filesystem
* @param File $fileHandler
* @param ReviewMediaFactory $reviewMediaFactory
* @param ReviewMedia $reviewMediaResourceModel
* @throws FileSystemException
*/
public function __construct(
RequestInterface $request,
Filesystem $filesystem,
File $fileHandler,
ReviewMediaFactory $reviewMediaFactory,
ReviewMedia $reviewMediaResourceModel
)
{
$this->request = $request;
$this->fileHandler = $fileHandler;
//$this->mediaDirectory = $filesystem->getDirectoryWrite(DirectoryList::MEDIA);
$this->reviewMediaFactory = $reviewMediaFactory;
$this->reviewMediaResourceModel = $reviewMediaResourceModel;
}
/**
* function
* executes after review is saved
*
* @param Observer $observer
* @return void
*/
public function execute(Observer $observer): void
{
//$target = $this->mediaDirectory->getAbsolutePath('review_images');
$deletedMediaString = $this->request->getParam('deleted_media');
if ($deletedMediaString)
try {
$ids = explode(",", trim($deletedMediaString, ","));
foreach ($ids as $id) {
$reviewMedia = $this->reviewMediaFactory->create()->load($id);
// $path = $target . $reviewMedia->getMediaUrl();
// if ($this->_fileHandler->isExists($path)) {
// $this->_fileHandler->deleteFile($path);
// }
//$reviewMedia->delete();
$this->reviewMediaResourceModel->delete($reviewMedia);
}
} catch (\Exception $e) {
$this->messageManager->addException($e, __('Something went wrong while updating review attachment(s).'));
}
}
}
<?php
/**
* NOTICE OF LICENSE
* You may not sell, distribute, sub-license, rent, lease or lend complete or portion of software to anyone.
*
* DISCLAIMER
* Do not edit or add to this file if you wish to upgrade to newer
* versions in the future.
*
* @package RLTSquare_ProductReviewImages
* @copyright Copyright (c) 2022 RLTSquare (https://www.rltsquare.com)
* @contacts support@rltsquare.com
* @license See the LICENSE.md file in module root directory
*/
namespace RLTSquare\ProductReviewImages\Observer;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\Event\Observer;
use Magento\Framework\Exception\FileSystemException;
use Magento\Framework\Filesystem;
use Magento\MediaStorage\Model\File\UploaderFactory;
use RLTSquare\ProductReviewImages\Model\ReviewMediaFactory;
use RLTSquare\ProductReviewImages\Model\ResourceModel\ReviewMedia;
/**
* Class ProductReviewSaveAfter
*
* @package RLTSquare\ProductReviewImages\Observer
* @author Umar Chaudhry <umarch@rltsquare.com>
*/
class ProductReviewSaveAfter implements \Magento\Framework\Event\ObserverInterface
{
/**
* @var RequestInterface
*/
protected RequestInterface $request;
/**
* @var ReviewMediaFactory
*/
protected ReviewMediaFactory $reviewMediaFactory;
/**
* @var DirectoryList::MEDIA
*/
protected $mediaDirectory;
/**
* @var UploaderFactory
*/
protected UploaderFactory $fileUploaderFactory;
/**
* @var ReviewMedia
*/
protected ReviewMedia $reviewMediaResourceModel;
/**
* ProductReviewSaveAfter constructor.
* @param RequestInterface $request
* @param Filesystem $filesystem
* @param UploaderFactory $fileUploaderFactory
* @param ReviewMediaFactory $reviewMediaFactory
* @throws FileSystemException
*/
public function __construct(
RequestInterface $request,
Filesystem $filesystem,
UploaderFactory $fileUploaderFactory,
ReviewMediaFactory $reviewMediaFactory,
ReviewMedia $reviewMediaResourceModel
)
{
$this->request = $request;
$this->fileUploaderFactory = $fileUploaderFactory;
$this->mediaDirectory = $filesystem->getDirectoryWrite(DirectoryList::MEDIA);
$this->reviewMediaFactory = $reviewMediaFactory;
$this->reviewMediaResourceModel = $reviewMediaResourceModel;
}
/**
* function
* executed after a product review is saved
*
* @param Observer $observer
* @return void
*/
public function execute(Observer $observer): void
{
$reviewId = $observer->getEvent()->getObject()->getReviewId();
$media = $this->request->getFiles('review_media');
$target = $this->mediaDirectory->getAbsolutePath('review_images');
if ($media) {
try {
for ($i = 0; $i < count($media); $i++) {
$uploader = $this->fileUploaderFactory->create(['fileId' => 'review_media[' . $i . ']']);
$uploader->setAllowedExtensions(['jpg', 'jpeg', 'png']);
$uploader->setAllowRenameFiles(true);
$uploader->setFilesDispersion(true);
$uploader->setAllowCreateFolders(true);
$result = $uploader->save($target);
$reviewMedia = $this->reviewMediaFactory->create();
$reviewMedia->setMediaUrl($result['file']);
$reviewMedia->setReviewId($reviewId);
// $reviewMedia->save();
$this->reviewMediaResourceModel->save($reviewMedia);
}
} catch (\Exception $e) {
if ($e->getCode() == 0) {
$this->messageManager->addError("Something went wrong while saving review attachment(s).");
}
}
}
}
}
# ProductReviewImages-Magento2
# Overview
The Product Review Images for Magento 2 extension has been developed by the product team at RLTSquare. This extension will allow your customers to upload images within default product reviews for the products they buy and can also show the unique ways they are using your products in real life. So, why not let your customers take an active part in your online eCommerce business and eventually get benefit from it?
Here are some of the salient features for the extension:
```
1. Allow your customers to upload images in Magento 2 default product reviews
2. Admin approval required to ensure relevant and appropriate images only to be viewed at frontend
3. Allows uploading of up to 10 product images
4. Allows potential customers to view the review images uploaded by other customers
5. Original image size results in good user experience
```
## Installation
### Magento® Marketplace
This extension will also be available on the Magento® Marketplace when approved.
### Manually
1. Go to Magento® 2 root folder
2. Require/Download this extension:
Enter following commands to install extension.
```
composer require rltsquare/product-review-images
```
Wait while composer is updated.
#### OR
You can also download code from this repo under Magento® 2 following directory:
```
app/code/RLTSquare/ProductReviewImages
```
3. Enter following commands to enable the module:
```
php bin/magento module:enable RLTSquare_ProductReviewImages
php bin/magento setup:upgrade
php bin/magento cache:clean
php bin/magento cache:flush
```
4. If Magento® is running in production mode, deploy static content:
```
php bin/magento setup:static-content:deploy
```
## Requirements
1. This Magento® extension works on Magento 2.1 and 2.2 versions. Tested on versions 2.1.6 and above.
2. Tested on different themes specifically Ultimo, Porto and certain custom themes
For details, read our blog:
https://www.rltsquare.com/blog/product-review-images-magento-2-extension/
{
"name": "rltsquare/product-review-images",
"description": "Magento 2 extension by RLTSquare that allows user to include images while submitting product reviews.",
"require": {
"php": "~7.0.3|~7.4.0|~8.1",
"magento/module-review" : ">100.1.2"
},
"type":"magento2-module",
"version": "1.0.6",
"license":[
"proprietary"
],
"authors":[
{
"name" : "Umar",
"email" : "umarch@rltsquare.com",
"homepage" : "https://www.rltsquare.com",
"role" : "Developer"
}
],
"autoload":{
"files": [
"registration.php"
],
"psr-4": {
"RLTSquare\\ProductReviewImages\\" : ""
}
}
}
<?xml version="1.0"?>
<!--
* NOTICE OF LICENSE
* You may not sell, distribute, sub-license, rent, lease or lend complete or portion of software to anyone.
*
* DISCLAIMER
* Do not edit or add to this file if you wish to upgrade to newer
* versions in the future.
*
* @package RLTSquare_ProductReviewImages
* @copyright Copyright (c) 2022 RLTSquare (https://www.rltsquare.com)
* @contacts support@rltsquare.com
* @license See the LICENSE.md file in module root directory
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="review_save_after">
<observer name="rltsquare_admin_product_review_save_after" instance="RLTSquare\ProductReviewImages\Observer\AdminProductReviewSaveAfter" />
</event>
<event name="review_delete_before">
<observer name="rltsquare_admin_product_review_delete_before" instance="RLTSquare\ProductReviewImages\Observer\AdminProductReviewDeleteBefore" />
</event>
</config>
\ No newline at end of file
<?xml version="1.0"?>
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
<table name="rltsquare_productreviewimages_reviewmedia" resource="default" engine="innodb" comment="RLTSqaure Product Review Images">
<column xsi:type="bigint" name="primary_id" unsigned="true" nullable="false" identity="true" comment="primary id of this table"/>
<column xsi:type="bigint" name="review_id" nullable="false" unsigned="true" comment="foreign key for review id"/>
<column xsi:type="text" name="media_url" nullable="false" comment="media url"/>
<constraint referenceId="PRIMARY" xsi:type="primary">
<column name="primary_id"/>
</constraint>
<constraint xsi:type="foreign" referenceId="PROVINCE_PROVINCE_ID_CITY_PROVINCE_ID" table="rltsquare_productreviewimages_reviewmedia" column="review_id" referenceTable="review" referenceColumn="review_id"/>
</table>
</schema>
{
"rltsquare_productreviewimages_reviewmedia": {
"column": {
"primary_id": true,
"review_id": true,
"media_url": true
},
"constraint": {
"PRIMARY": true,
"RLTSQUARE_PRDREVIEWIMAGES_REVIEWMDA_REVIEW_ID_REVIEW_REVIEW_ID": true
}
}
}
\ No newline at end of file
<?xml version="1.0"?>
<!--
* NOTICE OF LICENSE
* You may not sell, distribute, sub-license, rent, lease or lend complete or portion of software to anyone.
*
* DISCLAIMER
* Do not edit or add to this file if you wish to upgrade to newer
* versions in the future.
*
* @package RLTSquare_ProductReviewImages
* @copyright Copyright (c) 2022 RLTSquare (https://www.rltsquare.com)
* @contacts support@rltsquare.com
* @license See the LICENSE.md file in module root directory
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Magento\Review\Block\Form" type="RLTSquare\ProductReviewImages\Block\Form" />
<preference for="Magento\Review\Block\Adminhtml\Edit\Form" type="RLTSquare\ProductReviewImages\Block\Adminhtml\Edit\Form" />
</config>
\ No newline at end of file
<?xml version="1.0"?>
<!--
* NOTICE OF LICENSE
* You may not sell, distribute, sub-license, rent, lease or lend complete or portion of software to anyone.
*
* DISCLAIMER
* Do not edit or add to this file if you wish to upgrade to newer
* versions in the future.
*
* @package RLTSquare_ProductReviewImages
* @copyright Copyright (c) 2022 RLTSquare (https://www.rltsquare.com)
* @contacts support@rltsquare.com
* @license See the LICENSE.md file in module root directory
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="review_save_after">
<observer name="rltsquare_product_review_save_after" instance="RLTSquare\ProductReviewImages\Observer\ProductReviewSaveAfter" />
</event>
</config>
\ No newline at end of file
<?xml version="1.0"?>
<!--
* NOTICE OF LICENSE
* You may not sell, distribute, sub-license, rent, lease or lend complete or portion of software to anyone.
*
* DISCLAIMER
* Do not edit or add to this file if you wish to upgrade to newer
* versions in the future.
*
* @package RLTSquare_ProductReviewImages
* @copyright Copyright (c) 2022 RLTSquare (https://www.rltsquare.com)
* @contacts support@rltsquare.com
* @license See the LICENSE.md file in module root directory
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="RLTSquare_ProductReviewImages"/>
<sequence>
<module name="Magento_Review"/>
</sequence>
</config>
<?php
/**
* NOTICE OF LICENSE
* You may not sell, distribute, sub-license, rent, lease or lend complete or portion of software to anyone.
*
* DISCLAIMER
* Do not edit or add to this file if you wish to upgrade to newer
* versions in the future.
*
* @package RLTSquare_ProductReviewImages
* @copyright Copyright (c) 2022 RLTSquare (https://www.rltsquare.com)
* @contacts support@rltsquare.com
* @license See the LICENSE.md file in module root directory
*/
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE, 'RLTSquare_ProductReviewImages', __DIR__
);
\ No newline at end of file
<?php
/**
* NOTICE OF LICENSE
* You may not sell, distribute, sub-license, rent, lease or lend complete or portion of software to anyone.
*
* DISCLAIMER
* Do not edit or add to this file if you wish to upgrade to newer
* versions in the future.
*
* @package RLTSquare_ProductReviewImages
* @copyright Copyright (c) 2022 RLTSquare (https://www.rltsquare.com)
* @contacts support@rltsquare.com
* @license See the LICENSE.md file in module root directory
*/
use Magento\Framework\View\Element\Template;
?>
<?php
/**
*
* @var Escaper $escaper
*/
use Magento\Framework\Escaper;
/** @var $block Template */
?>
<?php if (count($block->getMediaCollection())): ?>
<div class="review-attachments">
<div class="review-media-value">
<?php
foreach ($block->getMediaCollection() as $m) {
$path = $block->getReviewMediaUrl() . $m->getMediaUrl();
?>
<div class="image item base-image" data-role="image">
<div class="product-image-wrapper">
<img class="product-image" data-role="image-element" src="<?php echo $path; ?>" alt="Image">
<div class="actions">
<button type="button" class="action-remove" media-id="<?php echo $m->getPrimaryId(); ?>" data-role="delete-button" title="Delete image">
<span>Delete image</span>
</button>
</div>
</div>
</div>
<?php
}
?>
</div>
</div>
<?php else: ?>
<?= $escaper->escapeHtml(__("No attachment available.")) ?>
<?php endif; ?>
<div id="review-image-modal" style="display:none;">
<img id="review-image-lg" src=""/>
</div>
<script>
require(
[
'jquery',
'Magento_Ui/js/modal/modal'
],
function ($) {
$('.action-remove').on('click', function (e) {
var mediaId = e.target.getAttribute('media-id');
$('#deleted_media').val($('#deleted_media').val() + mediaId + ",");
$(e.target).parent().parent().parent().remove();
});
$(".product-image").on('click', function () {
$("#review-image-modal").html("");
$("#review-image-modal").prepend('<img id="review-image-lg" src="' + $(this).attr("src") + '"/>');
$("#review-image-modal").modal({
type: 'popup',
title: 'Review Image',
clickableOverlay: true,
buttons:[],
responsive: true
}).modal('openModal').css({"text-align":"center"});
});
})
</script>
.image .product-image {
bottom: 0;
left: 0;
margin: auto;
max-height: 100%;
max-width: 100%;
position: absolute;
right: 0;
top: 0;
z-index: 1;
}
.image .product-image-wrapper {
background: #ffffff;
border: 1px solid #cccccc;
box-sizing: border-box;
cursor: pointer;
height: 150px;
line-height: 1;
margin-bottom: 1rem;
overflow: hidden;
position: relative;
width: 150px;
}
.image {
background: #ffffff;
box-sizing: border-box;
display: inline-block;
margin: 1.2rem;
position: relative;
vertical-align: top;
width: 150px;
}
.image .product-image-wrapper:hover .product-image {
opacity: .5;
}
\ No newline at end of file
<?xml version="1.0"?>
<!--
* NOTICE OF LICENSE
* You may not sell, distribute, sub-license, rent, lease or lend complete or portion of software to anyone.
*
* DISCLAIMER
* Do not edit or add to this file if you wish to upgrade to newer
* versions in the future.
*
* @package RLTSquare_ProductReviewImages
* @copyright Copyright (c) 2022 RLTSquare (https://www.rltsquare.com)
* @contacts support@rltsquare.com
* @license See the LICENSE.md file in module root directory
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<css src="RLTSquare_ProductReviewImages::rltsquare_productreviewimages.css"/>
</head>
</page>
<?xml version="1.0"?>
<!--
* NOTICE OF LICENSE
* You may not sell, distribute, sub-license, rent, lease or lend complete or portion of software to anyone.
*
* DISCLAIMER
* Do not edit or add to this file if you wish to upgrade to newer
* versions in the future.
*
* @package RLTSquare_ProductReviewImages
* @copyright Copyright (c) 2022 RLTSquare (https://www.rltsquare.com)
* @contacts support@rltsquare.com
* @license See the LICENSE.md file in module root directory
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
<referenceContainer name="product.info.details">
<referenceBlock name="product.info.product_additional_data">
<action method="setTemplate">
<argument name="template" xsi:type="string">RLTSquare_ProductReviewImages::product/view/list.phtml</argument>
</action>
</referenceBlock>
</referenceContainer>
</referenceContainer>Ï
</body>
</page>
<?xml version="1.0"?>
<!--
* NOTICE OF LICENSE
* You may not sell, distribute, sub-license, rent, lease or lend complete or portion of software to anyone.
*
* DISCLAIMER
* Do not edit or add to this file if you wish to upgrade to newer
* versions in the future.
*
* @package RLTSquare_ProductReviewImages
* @copyright Copyright (c) 2022 RLTSquare (https://www.rltsquare.com)
* @contacts support@rltsquare.com
* @license See the LICENSE.md file in module root directory
-->
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/layout_generic.xsd">
<referenceContainer name="root">
<referenceBlock name="product.info.product_additional_data">
<action method="setTemplate">
<argument name="template" xsi:type="string">RLTSquare_ProductReviewImages::product/view/list.phtml</argument>
</action>
</referenceBlock>
</referenceContainer>
</layout>
<?php
/**
* NOTICE OF LICENSE
* You may not sell, distribute, sub-license, rent, lease or lend complete or portion of software to anyone.
*
* DISCLAIMER
* Do not edit or add to this file if you wish to upgrade to newer
* versions in the future.
*
* @package RLTSquare_ProductReviewImages
* @copyright Copyright (c) 2022 RLTSquare (https://www.rltsquare.com)
* @contacts support@rltsquare.com
* @license See the LICENSE.md file in module root directory
*/
?>
<?php
/** @var Magento\Review\Block\Product\View\ListView $block */
/**
*
* @var Escaper $escaper
*/
?>
<?php
use Magento\Framework\Escaper;
?>
<?php
$_items = $block->getReviewsCollection()->getItems();
$format = $block->getDateFormat() ?: \IntlDateFormatter::SHORT;
$_objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$storeManager = $_objectManager->create('\Magento\Store\Model\StoreManagerInterface');
$mediaDirectoryPath = $storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA) . 'review_images';
?>
<?php if (count($_items)): ?>
<div class="block review-list" id="customer-reviews">
<div class="block-title">
<strong><?php /* @escapeNotVerified */
echo __('Customer Reviews') ?></strong>
</div>
<div class="block-content">
<div class="toolbar review-toolbar">
<?php echo $block->getChildHtml('toolbar') ?>
</div>
<ol class="items review-items">
<?php foreach ($_items as $_review): ?>
<li class="item review-item" itemscope itemprop="review" itemtype="http://schema.org/Review">
<div class="review-title"
itemprop="name"><?php echo $escaper->escapeHtml($_review->getTitle()) ?></div>
<?php if (count($_review->getRatingVotes())): ?>
<div class="review-ratings">
<?php foreach ($_review->getRatingVotes() as $_vote): ?>
<div class="rating-summary item" itemprop="reviewRating" itemscope
itemtype="http://schema.org/Rating">
<span class="label rating-label"><span><?php echo $escaper->escapeHtml($_vote->getRatingCode()) ?></span></span>
<div class="rating-result" title="<?php /* @escapeNotVerified */
echo $_vote->getPercent() ?>%">
<meta itemprop="worstRating" content="1"/>
<meta itemprop="bestRating" content="100"/>
<span style="width:<?php /* @escapeNotVerified */
echo $_vote->getPercent() ?>%">
<span itemprop="ratingValue"><?php /* @escapeNotVerified */
echo $_vote->getPercent() ?>%</span>
</span>
</div>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
<div class="review-content" itemprop="description">
<?php echo nl2br($escaper->escapeHtml($_review->getDetail())) ?>
</div>
<div class="review-details">
<p class="review-author">
<span class="review-details-label"><?php /* @escapeNotVerified */
echo __('Review by') ?></span>
<strong class="review-details-value"
itemprop="author"><?php echo $escaper->escapeHtml($_review->getNickname()) ?></strong>
</p>
<p class="review-date">
<span class="review-details-label"><?php /* @escapeNotVerified */
echo __('Posted on') ?></span>
<time class="review-details-value" itemprop="datePublished"
datetime="<?php /* @escapeNotVerified */
echo $block->formatDate($_review->getCreatedAt(), $format) ?>"><?php /* @escapeNotVerified */
echo $block->formatDate($_review->getCreatedAt(), $format) ?></time>
</p>
</div>
<div class="review-attachments">
<p class="review-attachments-label">Attachments</p>
<div class="review-media-value">
<?php
$thisReviewMediaCollection = $_objectManager->get('\RLTSquare\ProductReviewImages\Model\ReviewMediaFactory')
->create()
->getCollection()
->addFieldToFilter('review_id', $_review->getReviewId());
if (count($thisReviewMediaCollection))
foreach ($thisReviewMediaCollection as $m) {
?>
<div class="image item base-image" data-role="image">
<div class="product-image-wrapper">
<img class="product-image" data-role="image-element"
src="<?php echo rtrim($mediaDirectoryPath, '/') . $m->getMediaUrl(); ?>"
alt="Image">
</div>
</div>
<?php
}
else
echo __('No attachment available.');
?>
</div>
</div>
</li>
<?php endforeach; ?>
</ol>
<div id="review-image-modal" style="display:none;">
<img id="review-image-lg" src=""/>
</div>
<script>
require(
[
'jquery',
'Magento_Ui/js/modal/modal'
],
function ($, modal) {
$(".product-image").on('click', function () {
$("#review-image-modal").html("");
$("#review-image-modal").prepend('<img id="review-image-lg" src="' + $(this).attr("src") + '"/>');
$("#review-image-modal").modal({
type: 'popup',
title: 'Review Image',
clickableOverlay: true,
buttons: [],
responsive: true
}).modal('openModal').css({"text-align": "center"});
});
}
);
</script>
<div class="toolbar review-toolbar">
<?php echo $block->getChildHtml('toolbar') ?>
</div>
</div>
</div>
<?php endif; ?>
......@@ -10,6 +10,7 @@
// We should use strlen function because coupon code could be "0", converted to bool will lead to false
$hasCouponCode = (bool) strlen($block->getCouponCode());
?>
<div class="block discount"
id="block-discount"
......@@ -60,10 +61,3 @@ $hasCouponCode = (bool) strlen($block->getCouponCode());
</form>
</div>
</div>
<script>
require([
'jquery'
], function ($) {
});
</script>
......@@ -24,7 +24,7 @@ use Magento\Framework\Escaper;
class="action primary checkout<?= ($block->isDisabled()) ? ' disabled' : '' ?>"
<?php if ($block->isDisabled()): ?>
disabled="disabled"
<?php endif; ?> style=" background: #0000; height: 40px;font-size: 22px;text-transform: uppercase;font-weight: 400;padding: 14px 0 19px 0;">
<?php endif; ?> style=" background: #0000; height: 40px;font-size: 22px;text-transform: uppercase;font-weight: 400;">
<span data-v-20221108="" class="secure"><img data-v-b14bd780="" alt="" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADEAAAA3CAYAAAClxaIBAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTQ1IDc5LjE2MzQ5OSwgMjAxOC8wOC8xMy0xNjo0MDoyMiAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIDIwMTkgKFdpbmRvd3MpIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOjMyODNDODA2MkIwNTExRUNCNUFCRkFGMzY4RjkyOTdCIiB4bXBNTTpEb2N1bWVudElEPSJ4bXAuZGlkOjMyODNDODA3MkIwNTExRUNCNUFCRkFGMzY4RjkyOTdCIj4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9InhtcC5paWQ6MzI4M0M4MDQyQjA1MTFFQ0I1QUJGQUYzNjhGOTI5N0IiIHN0UmVmOmRvY3VtZW50SUQ9InhtcC5kaWQ6MzI4M0M4MDUyQjA1MTFFQ0I1QUJGQUYzNjhGOTI5N0IiLz4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz7niMRCAAAEKklEQVR42tSaW0gVQRjHt01SwiyTJKuHiugiEVIUVhBlPRRBN7ppUCT2EGVB0A2SoB6iJ596iPJBLJPM7B5SdDXNyjIxy0iLIsEoNYuu1vb/8DuwnM7OzszZPR7/8FNxZ3b2f+ab2ZlvTj/LsgyPlQhWgvlgNkgAXaAS3ABnQIenLZIJj0gGB8EHSyy6fgCM9KptL24yCOwFbZaaPnG9xN40EQ+2gxYrPL0DO/l+Ws/ST2NMDAM5YBMY42Fkt4BCUADeq1RUMTELrAVZIMnwT1/AKTZU5YWJiWAxWAOmG5HXA1AKroM6WRNxIJ1ZAqaCWKP3RQ9ZDS6AGnAf/LCbSMPvuWAeSAXjjOhXM2jk984tMvEUf0wx+q7qTX6b9mV9Nu2x1Uf1g0z8jsYQAY9AJq+/RPpp8rwcbQYaeEovAfEu5btMz1eU4RugN/Y62/9GuNRpj8GPzigx8Bjs5hebXaNc6nWQidYoMbCReyLUWk2k92TiXRQYoPB54XB9iEv9t6bqitGHMbBdYIBkCq79okgyOZxae8nAYd62Cgeu4NqbQE+08lo+0gbOgWKJsq9dTHSQib/gVYRNvAT7JctWOQx40nN7vNVFeI+QqVj+l8O1WruJ2giGUR7oVqgzQ7BIrbGnbAaCdstfPQVHFBIA48FVrhdKTYGyMezoG7taqPnpdvMsskC02gRbJO+5A2xw2efcCzUH39U0cAtM40brBeXyJe9ZIGGAdDNUBjBNMTQucpfb75HvUL5cMoTOC8LHru8gySl51ijx8NVghcND0Nh6EqLOOAkD1yQNkM7Z6wa/0ktdQqcMzARnHcrQ2CoPCqtKiffQNZCssNcvESWUJwvcD1WYWWptveCWnqxQ6AFSJ+d/HXuigfM7obReYcAXcm9cAV8F5S6D4YrZlqL/dqMhPplMwXh4CHIke4PGToLgepFiDwQ0SSYrPgC8kZiZkl1MjBVcy9c0UKGS2t8qcUOahVZrpOKzNQ2QMlRMxEqc+AR65ZCCgbQwDNzmKVzpkGWbwovvpISBATxOdJUOTFUT/UGzgpHzLibKwzBwTHRv0f71D8iVnPZoihwNrjpc3wPGai7fKS+2S5z4dw+DYsU11eWg+qlhjANLZvKQMTEYdCgaKQtaE+nqksyEESOTOgeb+RxNNrRIR/kwJFkzjGg3ly13jiQ/PR63IqtFfpxjm7zsiITy/DzHTuHMiG6IyIjCNkulgs5hfBqvdON8MEBb5DmqlUyNhqgnlvlgoMnoOTM3ImGCVKGYAHMTpVEzdE+tzDAapi3iKg8MPDN6ztG1k9pmmA9AX8CiQ/w2zfp32EB4ZyQefXGKshn1itPoSSuKvrRlX/UWShrY52G7npoIkMvJrVD6CJZ43aYfJogJ4HSQgRMgxY/2dF52KloOlnKy7YJfjfwTYAD0328CQiS8EQAAAABJRU5ErkJggg=="></span>
<span><?= $escaper->escapeHtml(__('Checkout Now')) ?></span>
</button>
......
......@@ -41,7 +41,7 @@
</if>
<if args="getCartParam('summary_count')">
<div class="items-total" style="display: block">
<div class="items-total" style="display: block;font-size: inherit;font-family: 'Outfit-Regular';">
<span class="count" if="maxItemsToDisplay < getCartLineItemsCount()" text="maxItemsToDisplay"></span>
<translate args="'of'" if="maxItemsToDisplay < getCartLineItemsCount()"></translate>
<span class="count" text="getCartParam('summary_count')"></span>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment