Tag Archives: Configuration

Default Nginx PHP-FPM Configuration

server {
listen 80;
server_name localhost;

# note that these lines are originally from the "location /" block
root /usr/share/nginx/html;
index index.php index.html index.htm;

location / {
try_files $uri $uri/ =404;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}

location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}

Magento 2 Allow NULL Value Multiselect System Configuration

It can be achieved bu adding the <can_be_empty>1</can_be_empty> tag in system.xml file

Ex:

<field id="hideprice" translate="label" type="multiselect" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Hide Price For</label>
<source_model>PHPCodez\Permission\Model\Config\Source\Group\Multiselect</source_model>
<can_be_empty>1</can_be_empty>
</field>

System Configuration Values Helpers Magento 2

<?php
namespace PHPCodez\Disableaddtocart\Helper;

use \Magento\Framework\App\Helper\AbstractHelper;
use \Magento\Framework\App\Config\ScopeConfigInterface;
use \Magento\Store\Model\ScopeInterface;
use \Magento\Customer\Model\Session;

class Data extends AbstractHelper {

protected $_scopeConfig;
protected $_customerSession;

public function __construct(ScopeConfigInterface $_scopeConfig,Session $_customerSession) {
$this->_scopeConfig = $_scopeConfig;
$this->_customerSession = $_customerSession;
}

public function getDisabledGroups($scope = ScopeConfigInterface::SCOPE_TYPE_DEFAULT) {
$disabledGroups = $this->_scopeConfig->getValue('phpcodez/parameters/disableaddtocart',ScopeInterface::SCOPE_STORE);
return $disabledGroups;
}

public function getCustomerGroup(){
return $this->_customerSession->isLoggedIn()?$this->_customerSession->getCustomer()->getGroupId():0;
}


}