Posts

Showing posts from February, 2018

Add Product Rating and Reviews in Magento2

Add This Code in Controller Or Use in Phtml <?php namespace Custom \Module\Controller\Index; use Magento\Framework\App\Action\Action; use Magento\Framework\App\Action\Context; class Productrating extends \Magento\Framework\App\Action\Action { public function __construct ( Context $context , \Magento\Review\Model\ReviewFactory $reviewFactory , \Magento\Review\Model\RatingFactory $ratingFactory , \Magento\Store\Model\StoreManagerInterface $storeManager ) { parent :: __construct ( $context ); $this -> _reviewFactory = $reviewFactory ; $this -> _ratingFactory = $ratingFactory ; $this -> _storeManager = $storeManager ; } public function execute () { $productid = 201 ; //product id you set accordingly $reviewdata [ 'ratings' ][ 1 ] = 5 ; //Rating First $reviewdata [ 'ratings' ][ 2 ] = 4 ; //Rating Second $r...

Change Customer Password Programmatically Magento 2

Add This Code In Controller <?php namespace Custom\Module\Controller\Index; use Magento\Framework\Encryption\EncryptorInterface as Encryptor; class Customerpassword extends \Magento\Framework\App\Action\Action { /** * @var \Magento\Framework\App\Cache\TypeListInterface */ protected $_cacheTypeList ; /** * @var \Magento\Framework\App\Cache\StateInterface */ protected $_cacheState ; /** * @var \Magento\Framework\App\Cache\Frontend\Pool */ protected $_cacheFrontendPool ; /** * @var \Magento\Framework\View\Result\PageFactory */ protected $resultPageFactory ; /** * @param Action\Context $context * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Framework\App\Cache\StateInterface $cacheState * @param \Magento\Framework\App\Cache\Frontend\Pool $cacheFrontendPool * @param \Magento\Framework\View\Result\PageFacto...

programmaticlly Create Order in Magento2 with custom options in order

<?php namespace Custom\Api\Controller\Index; use Magento\Framework\App\Action\Context; use Magento\Framework\View\Result\PageFactory; class Createbooking extends \Magento\Framework\App\Action\Action { /** * @var \Magento\Framework\App\Cache\TypeListInterface */ protected $_cacheTypeList ; /** * @var \Magento\Framework\App\Cache\StateInterface */ protected $_cacheState ; /** * @var \Magento\Framework\App\Cache\Frontend\Pool */ protected $_cacheFrontendPool ; /** * @var \Magento\Framework\View\Result\PageFactory */ protected $resultPageFactory ; /** * @param Action\Context $context * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Framework\App\Cache\StateInterface $cacheState * @param \Magento\Framework\App\Cache\Frontend\Pool $cacheFrontendPool * @param \Magento\Framework\View\Result\PageFactory $resultPageFact...