ltsecurityinc安防产品在线商城代码
This commit is contained in:
+42
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace Olegnax\Quickview\Plugin;
|
||||
|
||||
use Magento\Framework\App\Request\Http;
|
||||
|
||||
class AbstractProduct
|
||||
{
|
||||
|
||||
/**
|
||||
* @var Http
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* ResultPage constructor.
|
||||
*
|
||||
* @param Http $request
|
||||
*/
|
||||
public function __construct(Http $request)
|
||||
{
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Magento\Catalog\Block\Product\AbstractProduct $subject
|
||||
* @param $result
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function afterIsRedirectToCartEnabled(
|
||||
\Magento\Catalog\Block\Product\AbstractProduct $subject,
|
||||
$result
|
||||
) {
|
||||
$requestUri = (string)$this->request->getRequestUri();
|
||||
if (strpos($requestUri, 'ox_quickview/catalog_product/view') !== false) {
|
||||
$result = false;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
namespace Olegnax\Quickview\Plugin;
|
||||
|
||||
use Closure;
|
||||
use Magento\Catalog\Block\Product\View\Gallery;
|
||||
use Magento\Framework\App\Config\ScopeConfigInterface;
|
||||
use Magento\Framework\App\Request\Http;
|
||||
use Magento\Framework\Json\DecoderInterface;
|
||||
use Magento\Framework\Json\EncoderInterface;
|
||||
use Magento\Store\Model\ScopeInterface;
|
||||
|
||||
class BlockProductViewGalleryMagnifier
|
||||
{
|
||||
|
||||
/**
|
||||
* @var ScopeConfigInterface
|
||||
*/
|
||||
protected $scopeConfig;
|
||||
|
||||
/**
|
||||
* @var Http
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var EncoderInterface
|
||||
*/
|
||||
protected $jsonEncoder;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var DecoderInterface
|
||||
*/
|
||||
protected $jsonDecoder;
|
||||
|
||||
/**
|
||||
* ResultPage constructor.
|
||||
*
|
||||
* @param ScopeConfigInterface $scopeConfig
|
||||
* @param Http $request
|
||||
* @param EncoderInterface $jsonEncoder
|
||||
* @param DecoderInterface $jsonDecoder
|
||||
*/
|
||||
public function __construct(
|
||||
ScopeConfigInterface $scopeConfig,
|
||||
Http $request,
|
||||
EncoderInterface $jsonEncoder,
|
||||
DecoderInterface $jsonDecoder
|
||||
) {
|
||||
$this->request = $request;
|
||||
$this->scopeConfig = $scopeConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Gallery $subject
|
||||
* @param Closure $proceed
|
||||
* @param string $name
|
||||
* @param string|null $module
|
||||
*
|
||||
* @return string|false
|
||||
*/
|
||||
public function aroundGetVar(
|
||||
Gallery $subject,
|
||||
Closure $proceed,
|
||||
$name,
|
||||
$module = null
|
||||
) {
|
||||
$result = $proceed($name, $module);
|
||||
$isEnabled = $this->getSystemValue('olegnax_quickview/general/enable');
|
||||
|
||||
if (!$isEnabled || $this->request->getFullActionName() != 'ox_quickview_catalog_product_view') {
|
||||
return $result;
|
||||
}
|
||||
|
||||
switch ($name) {
|
||||
case "gallery/navdir" :
|
||||
$result = 'horizontal';
|
||||
break;
|
||||
/* Disable the image fullscreen on quickview*/
|
||||
case "gallery/allowfullscreen" :
|
||||
$result = false;
|
||||
break;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getSystemValue($path, $storeCode = null)
|
||||
{
|
||||
return $this->scopeConfig->getValue($path, ScopeInterface::SCOPE_STORE, $storeCode);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace Olegnax\Quickview\Plugin;
|
||||
|
||||
use Magento\Checkout\Controller\Cart\Add;
|
||||
use Magento\Framework\App\Request\Http;
|
||||
use Magento\Framework\Json\EncoderInterface;
|
||||
|
||||
class CartAdd
|
||||
{
|
||||
|
||||
/**
|
||||
* @var Http
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var EncoderInterface
|
||||
*/
|
||||
protected $jsonEncoder;
|
||||
|
||||
/**
|
||||
* ResultPage constructor.
|
||||
*
|
||||
* @param Http $request
|
||||
* @param EncoderInterface $jsonEncoder
|
||||
*/
|
||||
public function __construct(
|
||||
Http $request,
|
||||
EncoderInterface $jsonEncoder
|
||||
) {
|
||||
$this->request = $request;
|
||||
$this->jsonEncoder = $jsonEncoder;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Add $subject
|
||||
* @param $result
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function afterExecute(
|
||||
Add $subject,
|
||||
$result
|
||||
) {
|
||||
/** Fix for product redirects, ex. when quantity is out of stock */
|
||||
$refererUrl = (string)$this->request->getServer('HTTP_REFERER');
|
||||
if (strpos($refererUrl, 'ox_quickview/catalog_product/view') !== false) {
|
||||
return $subject->getResponse()->representJson($this->jsonEncoder->encode([]));
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace Olegnax\Quickview\Plugin;
|
||||
|
||||
use Closure;
|
||||
use Magento\Catalog\Model\Product;
|
||||
use Magento\Framework\App\Config\ScopeConfigInterface;
|
||||
use Magento\Framework\UrlInterface;
|
||||
use Magento\Store\Model\ScopeInterface;
|
||||
|
||||
class ListProduct
|
||||
{
|
||||
|
||||
/**
|
||||
* @var UrlInterface
|
||||
*/
|
||||
protected $urlInterface;
|
||||
|
||||
/**
|
||||
* @var ScopeConfigInterface
|
||||
*/
|
||||
protected $scopeConfig;
|
||||
|
||||
/**
|
||||
* @param UrlInterface $urlInterface
|
||||
* @param ScopeConfigInterface $scopeConfig
|
||||
*/
|
||||
public function __construct(
|
||||
UrlInterface $urlInterface,
|
||||
ScopeConfigInterface $scopeConfig
|
||||
) {
|
||||
$this->urlInterface = $urlInterface;
|
||||
$this->scopeConfig = $scopeConfig;
|
||||
}
|
||||
|
||||
public function aroundGetProductDetailsHtml(
|
||||
\Magento\Catalog\Block\Product\ListProduct $subject,
|
||||
Closure $proceed,
|
||||
Product $product
|
||||
) {
|
||||
$result = $proceed($product);
|
||||
$isEnabled = $this->getConfig('olegnax_quickview/general/enable');
|
||||
if ($isEnabled) {
|
||||
$productUrl = $this->urlInterface->getUrl('ox_quickview/catalog_product/view',
|
||||
array('id' => $product->getId()));
|
||||
return $result . '<a class="ox-quickview-button" data-quickview-url="' . $productUrl . '" href="#"><span>' . __("Quickview") . '</span></a>';
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getConfig($path, $storeCode = null)
|
||||
{
|
||||
return $this->getSystemValue($path, $storeCode);
|
||||
}
|
||||
|
||||
public function getSystemValue($path, $storeCode = null)
|
||||
{
|
||||
return $this->scopeConfig->getValue($path, ScopeInterface::SCOPE_STORE, $storeCode);
|
||||
}
|
||||
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace Olegnax\Quickview\Plugin;
|
||||
|
||||
use Magento\Framework\App\Request\Http;
|
||||
use Magento\Framework\View\Layout;
|
||||
use Magento\Framework\View\Result\Page;
|
||||
|
||||
class ResultPage
|
||||
{
|
||||
|
||||
/**
|
||||
* @var Http
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* @var Layout
|
||||
*/
|
||||
protected $layout;
|
||||
|
||||
/**
|
||||
* ResultPage constructor.
|
||||
*
|
||||
* @param Http $request
|
||||
* @param Layout $layout
|
||||
*/
|
||||
public function __construct(
|
||||
Http $request,
|
||||
Layout $layout
|
||||
) {
|
||||
$this->request = $request;
|
||||
$this->layout = $layout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adding the default catalog_product_view_type_ handles as well
|
||||
*
|
||||
* @param Page $subject
|
||||
* @param array $parameters
|
||||
* @param mixed $defaultHandle
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function beforeAddPageLayoutHandles(
|
||||
Page $subject,
|
||||
array $parameters = [],
|
||||
$defaultHandle = null
|
||||
) {
|
||||
if ($this->request->getFullActionName() == 'ox_quickview_catalog_product_view') {
|
||||
return [$parameters, 'catalog_product_view'];
|
||||
} else {
|
||||
return [$parameters, $defaultHandle];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace Olegnax\Quickview\Plugin;
|
||||
|
||||
use Closure;
|
||||
use Magento\Framework\App\Config\ScopeConfigInterface;
|
||||
use Magento\Framework\App\Request\Http;
|
||||
|
||||
class ScopeConfig
|
||||
{
|
||||
|
||||
/**
|
||||
* @var Http
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* ResultPage constructor.
|
||||
*
|
||||
* @param Http $request
|
||||
*/
|
||||
public function __construct(Http $request)
|
||||
{
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ScopeConfigInterface $subject
|
||||
* @param Closure $proceed
|
||||
* @param $path
|
||||
* @param $scopeType
|
||||
* @param null $scopeCode
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function aroundGetValue(
|
||||
ScopeConfigInterface $subject,
|
||||
Closure $proceed,
|
||||
$path = '',
|
||||
$scopeType = ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
|
||||
$scopeCode = null
|
||||
) {
|
||||
$result = $proceed($path, $scopeType, $scopeCode);
|
||||
|
||||
if (($path == 'checkout/cart/redirect_to_cart')) {
|
||||
$refererUrl = (string)$this->request->getServer('HTTP_REFERER');
|
||||
if (strpos($refererUrl, 'ox_quickview/catalog_product/view') !== false) {
|
||||
$result = false;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user