How to add external CSS and JS Url in Magento2?

You can add External third-party JS,CSS, and fonts URL using Magento 2 by XML at below way, All the Url will be staying in  <head> tag. Pass Second attribute as  src_type=”url”

For set third-party JS link,

<head>
	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js" src_type="url" />
</head>

For set third-party CSS link,

<head>
	<css src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap-theme.min.css" src_type="url" />
</head>

For set font link,

<head>
	<link src="http://fonts.googleapis.com/css?family=Montserrat" src_type="url" />
</head>

For Remove link from the page,  If you want to remove specific JS or CSS from the specific page you can use <remove> tag under the <head> to remove from a specific page.

<head>
    <remove src="ttps://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js" />
    <remove src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap-theme.min.css" />
    <remove src="http://fonts.googleapis.com/css?family=Montserrat" />
</head>

 

How to get Value from Store Configuration by Scope in Magento 2?

To Fetch the System Store Configuration Values by Scope level, Store or Website, You need to use ScopeConfigInterface with getValue() method.

We can get the Core config data table value programmatically using the given way,

public function __construct(
    \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
    \Magento\Store\Model\StoreManagerInterface $storeManager
) {
    $this->scopeConfig = $scopeConfig;
    $this->storeManager = $storeManager;
}

Now call in a function,

public function getConfigValue() {
    return $this->scopeConfig->getValue("sectionId/groupId/fieldId",
                \Magento\Store\Model\ScopeInterface::SCOPE_STORE,$this->storeManager->getStore()->getStoreId();
}

First Argument sectionId/groupId/fieldId is from your etc/adminhtml/system.xml file.

The second Argument will be the Scope Value.

Third Argument will be scopeCode. It may be int, string or null value.

Demo system.xml to illustrate the example,

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
    <system>
        <section id="test" translate="label" type="text" sortOrder="310" showInDefault="1" showInWebsite="1" showInStore="1">
            <label>Test Settings</label>
            <group id="origin" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="0">
                <label>Main label</label>
                <field id="postcode" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="0" canRestore="1">
                    <label>Postal Code</label>
                </field>
            </group>
        </section>
    </system>
</config>

In our case test/origin/postcode is the key value for sectionId/groupId/fieldId.

How to override magento 2 order/items/renderer/default.phtml?

We can override default.phtml file using below way,
Create sales_order_item_renderers.xml in your module layout folder,
File path will be in your module,
app/code/Rbj/Training/view/frontend/layout/sales_order_item_renderers.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="sales.order.items.renderers">
            <block class="Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer"
                   name="sales.order.items.renderer.default.configurable" as="configurable"
                   template="Rbj_Training::order/items/renderer/default.phtml"/>
            <block class="Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer"
                   name="sales.order.items.renderer.default.simple" as="simple"
                   template="Rbj_Training::order/items/renderer/default.phtml"/>
            <block class="Magento\Downloadable\Block\Sales\Order\Item\Renderer\Downloadable"
                   name="sales.order.items.renderer.downloadable" as="downloadable"
                   template="Rbj_Training::order/items/renderer/default.phtml"/>
            <block class="Magento\Bundle\Block\Sales\Order\Items\Renderer"
                   name="sales.order.items.renderers.bundle" as="bundle"
                   template="Rbj_Training::order/items/renderer/bundle/renderer.phtml"/>
            <block class="Magento\GroupedProduct\Block\Order\Item\Renderer\Grouped"
                   name="sales.order.items.renderers.grouped" as="grouped"
                   template="Rbj_Training::order/items/renderer/default.phtml"/>
        </referenceBlock>
    </body>
</page>

Replace Rbj_Training with your actual module name.

Clear Cache and check your file will be overridden.