This repository has been archived by the owner on Jul 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit bf0231d
Showing
41 changed files
with
2,905 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.buildpath | ||
.project | ||
.settings/ | ||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
dist: trusty | ||
|
||
language: php | ||
|
||
php: | ||
- 7.0 | ||
- 7.1 | ||
- 7.2 | ||
- 7.3 | ||
|
||
before_install: | ||
- composer create-project magento/magento-coding-standard --stability=dev magento-coding-standard | ||
- cd magento-coding-standard | ||
|
||
script: | ||
- vendor/bin/phpcs --ignore=../magento-coding-standard/* --standard=Magento2 --extensions=php ../. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace GhoSter\Quickview\Block; | ||
|
||
use Magento\Framework\View\Element\Template\Context; | ||
use Magento\Framework\Exception\NoSuchEntityException; | ||
use GhoSter\Quickview\Model\Config as QuickViewConfig; | ||
use Magento\Framework\View\Element\Template; | ||
|
||
/** | ||
* Class Initialize block init the js | ||
*/ | ||
class Initialize extends Template | ||
{ | ||
/** @var QuickViewConfig */ | ||
protected $config; | ||
|
||
/** | ||
* @param QuickViewConfig $config | ||
* @param Context $context | ||
* @param array $data | ||
*/ | ||
public function __construct( | ||
QuickViewConfig $config, | ||
Context $context, | ||
array $data = [] | ||
) { | ||
$this->config = $config; | ||
parent::__construct($context, $data); | ||
} | ||
|
||
/** | ||
* @return array | ||
* @throws NoSuchEntityException | ||
*/ | ||
public function getConfig() | ||
{ | ||
return [ | ||
'baseUrl' => $this->_storeManager->getStore()->getBaseUrl() | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
<?php | ||
|
||
namespace GhoSter\Quickview\Block; | ||
|
||
use Magento\Catalog\Model\Product; | ||
use Magento\Customer\Model\Context as CustomerContext; | ||
use Magento\Framework\App\Http\Context as HttpContext; | ||
use Magento\Framework\View\Element\Template\Context; | ||
use Magento\Framework\DataObject\IdentityInterface; | ||
use Magento\Framework\View\Element\Template; | ||
use Magento\Framework\Json\EncoderInterface; | ||
use GhoSter\Quickview\Model\Config; | ||
|
||
/** | ||
* Class QuickViewButton for rendering the button | ||
*/ | ||
class QuickViewButton extends Template implements IdentityInterface | ||
{ | ||
/** | ||
* Cache tag prefix | ||
*/ | ||
const CACHE_TAG = 'ghoster_quickview'; | ||
|
||
/** @var string */ | ||
protected $_template = 'GhoSter_Quickview::button.phtml'; | ||
|
||
/** @var Product */ | ||
private $product; | ||
|
||
/** @var HttpContext */ | ||
private $httpContext; | ||
|
||
/** @var EncoderInterface */ | ||
private $jsonEncoder; | ||
|
||
/** @var Config */ | ||
protected $quickViewConfig; | ||
|
||
/** @var int */ | ||
private $storeId; | ||
|
||
/** @var int */ | ||
private $themeId; | ||
|
||
/** | ||
* QuickViewButton constructor. | ||
* @param Context $context | ||
* @param HttpContext $httpContext | ||
* @param EncoderInterface $jsonEncoder | ||
* @param Config $quickViewConfig | ||
* @param array $data | ||
* @throws \Magento\Framework\Exception\NoSuchEntityException | ||
*/ | ||
public function __construct( | ||
Context $context, | ||
HttpContext $httpContext, | ||
EncoderInterface $jsonEncoder, | ||
Config $quickViewConfig, | ||
array $data = [] | ||
) { | ||
parent::__construct($context, $data); | ||
$this->httpContext = $httpContext; | ||
$this->jsonEncoder = $jsonEncoder; | ||
$this->quickViewConfig = $quickViewConfig; | ||
$this->product = $data['product'] ?? null; | ||
$this->storeId = $this->_storeManager->getStore()->getId(); | ||
$this->themeId = $this->_design->getDesignTheme()->getId(); | ||
$this->addData([ | ||
'cache_lifetime' => 86400 | ||
]); | ||
} | ||
|
||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getJsonConfig() | ||
{ | ||
$productId = $this->getProduct()->getId(); | ||
|
||
return $this->jsonEncoder->encode( | ||
[ | ||
'position' => 'top-center', | ||
'path' => $this->getContainerPath(), | ||
'closeSeconds' => 5, | ||
'mode' => 'cat', | ||
'product' => $productId, | ||
'margin' => 10, | ||
'alignment' => 0 | ||
] | ||
); | ||
} | ||
|
||
/** | ||
* @return boolean|int | ||
*/ | ||
public function isAdminArea() | ||
{ | ||
return $this->getArea() == 'adminhtml'; | ||
} | ||
|
||
/** | ||
* @return array | ||
* @throws \Magento\Framework\Exception\NoSuchEntityException | ||
*/ | ||
public function getCacheKeyInfo() | ||
{ | ||
$productId = $this->getProduct()->getId(); | ||
|
||
return [ | ||
'GHOSTER_PRODUCT_QUICK_VIEW', | ||
$this->storeId, | ||
$this->themeId, | ||
$this->httpContext->getValue(CustomerContext::CONTEXT_GROUP), | ||
'template' => $this->getTemplate(), | ||
$productId | ||
]; | ||
} | ||
|
||
/** | ||
* @return array|string[] | ||
*/ | ||
public function getIdentities() | ||
{ | ||
return array_merge( | ||
($this->getProduct() instanceof IdentityInterface) ? $this->getProduct()->getIdentities() : [], | ||
[self::CACHE_TAG . '_' . $this->getProduct()->getId()] | ||
); | ||
} | ||
|
||
/** | ||
* @param Product $product | ||
* | ||
* @return $this | ||
*/ | ||
public function setProduct(Product $product) | ||
{ | ||
$this->product = $product; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @return Product | ||
*/ | ||
public function getProduct() | ||
{ | ||
return $this->product; | ||
} | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
public function getContainerPath() | ||
{ | ||
return $this->quickViewConfig->getContainerPath(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace GhoSter\Quickview\Controller\Catalog\Product; | ||
|
||
use Magento\Framework\App\Action\Context; | ||
use Magento\Framework\View\Result\PageFactory; | ||
|
||
class View extends \Magento\Catalog\Controller\Product\View | ||
{ | ||
|
||
} |
Oops, something went wrong.