1 08, 2015

Magento 2: Add new tab in Product detail page

August 1st, 2015|MAGENTO, MAGENTO 2|2 Comments

In Magento 2 to apply the new tab in product detail page is very easy task. Use below steps and check it out. It will display the tab in your theme.

1. Create file “catalog_product_view.xml” in the app/design/frontend/{vender name}/{theme name}/Magento_Catalog/layout

In the file write the below code:

29 07, 2015

Magento 2: Resize the image

July 29th, 2015|MAGENTO, MAGENTO 2|2 Comments

There are minor changes in magento 2 to resize image, please use below code for resize the image in magento 2
For DirectoryList we can use this class […]

29 07, 2015

Magento 2: Upload the image from admin side

July 29th, 2015|MAGENTO, MAGENTO 2|0 Comments

Here is code for upload the image from admin side in magento 2:

use Magento\Framework\App\Filesystem\DirectoryList;

public function __construct(

\Magento\MediaStorage\Model\File\UploaderFactory $fileUploaderFactory,

) {

$this->_fileUploaderFactory = $fileUploaderFactory;

}

public function uploadImage(){

$uploader = $this->_fileUploaderFactory->create(['fileId' => 'image']);

$uploader->setAllowedExtensions(['jpg', 'jpeg', 'gif', 'png']);

$uploader->setAllowRenameFiles(false);

$uploader->setFilesDispersion(true);

$path = $this->_filesystem->getDirectoryRead(DirectoryList::MEDIA)

->getAbsolutePath('{moduleName}/');

$result = $uploader->save($path);

}

 

29 07, 2015

Magento 2: Create the Contact us page by CMS

July 29th, 2015|MAGENTO, MAGENTO 2|0 Comments

Here, we need to create the different contact us page. We want the different url for contact us page. So for this we will create the new cms page.

In the cms page content we write the following code to display the cms page form

{{block [...]

29 07, 2015

Magento 2: Create Featured Product Module

July 29th, 2015|MAGENTO, MAGENTO 2|5 Comments

We are very exciting after we have successfully created featured product module and We want to share with you.
Let’s create the featured product module. We will need
app/code/Webmull/Featuredproduct/Block

app/code/Webmull/Featuredproduct/etc

app/code/Webmull/Featuredproduct/Setup

app/code/Webmull/Featuredproduct/view/frontend/templates

Now, We have created directory structure for the module. Now we will create the file for this.

1. First we create the configuration file module.xml in app/code/Webmull/Featuredproduct/etc

The […]

29 07, 2015

Magento 2: get the Current Url

July 29th, 2015|MAGENTO, MAGENTO 2|0 Comments

We can use below syntax to get current Url:

protected $_urlinterface;


public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Framework\UrlInterface $urlinterface,
array $data = []
) {
parent::__construct($context, $data);
$this->_urlinterface = $urlinterface;
}


public function getCurrentUrl()
{
return $this->_urlinterface->getCurrentUrl(); // Give the current url of recently viewed page
}

 

29 07, 2015

Magento 2: getBase url

July 29th, 2015|MAGENTO, MAGENTO 2|0 Comments

Here is code for get Base URL in magento 2:

public function getBaseUrl()
{
return $this->_storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA);
}

 

29 07, 2015

Magento 2: Get the Current Store

July 29th, 2015|MAGENTO, MAGENTO 2|0 Comments

Here is code for get current store in magento 2:

 protected $_storeManager;


public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Store\Model\StoreManagerInterface $storeManager,
array $data = []
) {
parent::__construct($context, $data);
$this->_storeManager = $storeManager;
}


public function getCurrentStore(){
return $this->_storeManager->getStore(); // give the information about current store
}

 

29 07, 2015

Magento 2: Create New Custom theme

July 29th, 2015|MAGENTO, MAGENTO 2|0 Comments

In magento 2, all the file structure is changed compare to older version. So let’s start to create new theme in magento 2

Create Theme Directory

  1. Go to the magento Directory
  2. Create the directory <vendor> in the path app/design/frontend. <Vender> Should be the interface or package name for theme.
  3. Create the theme folder on […]
9 07, 2015

Magento 2: Get Currency Symbol

July 9th, 2015|MAGENTO, MAGENTO 2|1 Comment

To get the currency code and symbol, you need to write the code in .php file

protected $_storeManager;


public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Store\Model\StoreManagerInterface $storeManager,
array $data = []
) {
parent::__construct($context, $data);
$this->_storeManager = $storeManager;
}


public function getCurrencyData(){
$currencyCode = $this->_storeManager->getStore()->getCurrentCurrencyCode(); // give the currency code
$currencyRate = $this->_storeManager->getStore()->getCurrentCurrencyRate(); // give the currency rate
}

[…]