Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
- <type name="MagentoCatalogBlockProductImage">
- <plugin name="Wishlist_Count::Count" type="WishlistCountPluginCatalogProductWishcount"/>
- </type>
- </config>
- namespace WishlistCountPluginCatalogProductView;
- class Wishcount
- {
- protected $_helper;
- protected $scopeConfig;
- public function __construct(
- WishlistCountHelperData $helper,
- MagentoFrameworkAppConfigScopeConfigInterface $scopeConfig
- ) {
- $this->_helper = $helper;
- $this->_scopeConfig = $scopeConfig;
- }
- public function afterToHtml(
- MagentoCatalogBlockProductViewGallery $subject,
- $result
- ) {
- $product = $subject->getProduct();
- $template = $subject->getTemplate();//view/frontend/templates/product/view/gallery.phtml
- $name = $subject->getNameInLayout();
- if ($product && $name == "product.info.media.image") {
- $result .= $this->_helper->renderWishlistCount( $product );
- }
- return $result;
- } }
- namespace WishlistCountHelper;
- use MagentoFrameworkAppFilesystemDirectoryList;
- use MagentoStoreModelScopeInterface;
- class Data extends MagentoFrameworkAppHelperAbstractHelper
- {
- protected $_storeManager;
- protected $_counts;
- protected $_registry;
- protected $_resultPageFactory;
- protected $_objectManager;
- protected $_messageManager;
- protected $_scopeConfig;
- protected $_statusId = null;
- private $layoutFactory;
- private $_productTypeConfigurable;
- public function __construct(
- MagentoFrameworkRegistry $registry,
- MagentoFrameworkViewResultPageFactory $resultPageFactory,
- MagentoFrameworkObjectManagerInterface $objectManager,
- MagentoFrameworkMessageManagerInterface $messageManager,
- MagentoStoreModelStoreManagerInterface $storeManager,
- MagentoFrameworkViewLayoutFactory $layoutFactory,
- MagentoConfigurableProductModelProductTypeConfigurable $catalogProductTypeConfigurable,
- MagentoFrameworkAppHelperContext $context
- ) {
- parent::__construct($context);
- $this->_registry = $registry;
- $this->_resultPageFactory = $resultPageFactory;
- $this->_objectManager = $objectManager;
- $this->_messageManager = $messageManager;
- $this->_scopeConfig = $context->getScopeConfig();
- $this->_storeManager = $storeManager;
- $this->layoutFactory = $layoutFactory;
- $this->_productTypeConfigurable = $catalogProductTypeConfigurable;
- }
- public function renderWishlistCount(MagentoCatalogModelProduct $product)
- {
- $html = '';
- $id = $this->_storeManager->getStore(true)->getId();
- $model = $this->_objectManager->create('MagentoWishlistModelWishlist');
- $html = $model->getCollection()
- ->addFieldToFilter('store_id', ['like' => "%$id%"])
- ->addFieldToFilter('product_id', ['like' => "%$product->getId()%"])
- return $html;
- }
- }
Add Comment
Please, Sign In to add comment