Guest User

Untitled

a guest
Oct 20th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.08 KB | None | 0 0
  1. <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
  2. <type name="MagentoCatalogBlockProductImage">
  3. <plugin name="Wishlist_Count::Count" type="WishlistCountPluginCatalogProductWishcount"/>
  4. </type>
  5. </config>
  6.  
  7. namespace WishlistCountPluginCatalogProductView;
  8. class Wishcount
  9. {
  10. protected $_helper;
  11. protected $scopeConfig;
  12.  
  13. public function __construct(
  14. WishlistCountHelperData $helper,
  15. MagentoFrameworkAppConfigScopeConfigInterface $scopeConfig
  16. ) {
  17. $this->_helper = $helper;
  18. $this->_scopeConfig = $scopeConfig;
  19. }
  20. public function afterToHtml(
  21. MagentoCatalogBlockProductViewGallery $subject,
  22. $result
  23. ) {
  24. $product = $subject->getProduct();
  25. $template = $subject->getTemplate();//view/frontend/templates/product/view/gallery.phtml
  26. $name = $subject->getNameInLayout();
  27. if ($product && $name == "product.info.media.image") {
  28. $result .= $this->_helper->renderWishlistCount( $product );
  29. }
  30. return $result;
  31. } }
  32.  
  33. namespace WishlistCountHelper;
  34. use MagentoFrameworkAppFilesystemDirectoryList;
  35. use MagentoStoreModelScopeInterface;
  36.  
  37. class Data extends MagentoFrameworkAppHelperAbstractHelper
  38. {
  39. protected $_storeManager;
  40. protected $_counts;
  41. protected $_registry;
  42. protected $_resultPageFactory;
  43. protected $_objectManager;
  44. protected $_messageManager;
  45. protected $_scopeConfig;
  46. protected $_statusId = null;
  47. private $layoutFactory;
  48. private $_productTypeConfigurable;
  49.  
  50. public function __construct(
  51. MagentoFrameworkRegistry $registry,
  52. MagentoFrameworkViewResultPageFactory $resultPageFactory,
  53. MagentoFrameworkObjectManagerInterface $objectManager,
  54. MagentoFrameworkMessageManagerInterface $messageManager,
  55. MagentoStoreModelStoreManagerInterface $storeManager,
  56. MagentoFrameworkViewLayoutFactory $layoutFactory,
  57. MagentoConfigurableProductModelProductTypeConfigurable $catalogProductTypeConfigurable,
  58. MagentoFrameworkAppHelperContext $context
  59. ) {
  60. parent::__construct($context);
  61. $this->_registry = $registry;
  62. $this->_resultPageFactory = $resultPageFactory;
  63. $this->_objectManager = $objectManager;
  64. $this->_messageManager = $messageManager;
  65. $this->_scopeConfig = $context->getScopeConfig();
  66. $this->_storeManager = $storeManager;
  67. $this->layoutFactory = $layoutFactory;
  68. $this->_productTypeConfigurable = $catalogProductTypeConfigurable;
  69. }
  70.  
  71. public function renderWishlistCount(MagentoCatalogModelProduct $product)
  72. {
  73. $html = '';
  74.  
  75. $id = $this->_storeManager->getStore(true)->getId();
  76. $model = $this->_objectManager->create('MagentoWishlistModelWishlist');
  77. $html = $model->getCollection()
  78. ->addFieldToFilter('store_id', ['like' => "%$id%"])
  79. ->addFieldToFilter('product_id', ['like' => "%$product->getId()%"])
  80.  
  81. return $html;
  82. }
  83. }
Add Comment
Please, Sign In to add comment