Posted on June 18, 2016, 3:25 pm, by admin, under
Magento 2.0.
<?php namespace Imran\Test\Controller\Index; use \Magento\Framework\App\Action\Action; class Index extends Action { /** * @var \Magento\Framework\View\Result\Page */ protected $resultPageFactory; /** * @param \Magento\Framework\App\Action\Context $context */ public function __construct(\Magento\Framework\App\Action\Context $context, \Magento\Framework\View\Result\PageFactory $resultPageFactory) { parent::__construct($context); $this->resultPageFactory = $resultPageFactory; $this->resultRedirectFactory->create()->setUrl(’https://www.someurl.com’); } }
find /var/www/magento2 -type f -print0 | xargs -r0 chmod 640 find /var/www/magento2 -type d -print0 | xargs -r0 chmod 750 chmod -R g+w /var/www/magento2/{pub,var}
Magento 2 keeps db configuration in app/etc/env.php
1. Run the following: mkdir $MAGENTODIR/app/code/vendorname/modulename cd $MAGENTODIR bin/magento module:status output: List of disabled modules: Vendorname_Modulename 2. Follow by: bin/magento module:enable Vendor_Module bin/magento setup:upgrade 3. If asks for compile do the following: bin/magento setup:di:compile
<?php namespace Imran\Test\Controller\Index; use \Magento\Framework\App\Action\Action; class Index extends Action { /** @var \Magento\Framework\View\Result\Page */ protected $resultPageFactory; /** * @param \Magento\Framework\App\Action\Context $context */ public function __construct(\Magento\Framework\App\Action\Context $context, \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory) { parent::__construct($context); $this->resultJsonFactory = $resultJsonFactory; } /** * Blog Index, shows a list of recent blog posts. * * @return \Magento\Framework\View\Result\JsonFactory */ public […]
<?php … $subscribe = $this->_objectManager->create(’Imran\Test\Model\Subscriber’); // Get by ID $item = $subscribe->load(19); echo $item->getName(); // Get by Email $subs = $subscribe->getCollection()->addFieldToFilter(’email’, ‘aa@bb.com’); foreach ($subs as $sub) { var_dump($sub->getData()); } …
<?php … $subscribe = $this->_objectManager->create(’Imran\Test\Model\Subscriber’); // Method 1 $subs = $subscribe->getCollection()->addFieldToFilter(’email’, ‘aa@bb.com’); var_dump($subs->getFirstItem()->getData()); // Method 2 $subs = $subscribe->getCollection() ->setPageSize(1) ->addFieldToFilter(’email’, ‘aa@bb.com’); foreach ($subs as $sub) { var_dump($sub->getData()); } …
Design customizations kept under: app/design/Vendor/theme/Vendor_Modulename/web/css app/design/Vendor/theme/Vendor_Modulename/layout app/design/Vendor/theme/Vendor_Modulename/templates
Go to Stores -> Configuration -> Content Management -> Enable WYSIWYG Editor: Disabled by Default / Disabled Completely
1. change setup_version in app/code/Vendor/Module/etc/module.xml 2. run bin/magento setup:db-schema:upgrade