Using javascript variables in x-magento init tags

The below code errors out unexpected token :

<script>var myJSVariable = '';</script>  <script type="text/x-magento-init">         {             "*": {                 "js/async_templates": {                                 "template_code": "rv",                                 "selector" : "#rv-content",                                 "isAjax" : "true",                                 "product_id" : "<?php echo $  this->getCurrentProduct()->getId() ?>",                                 "rvp" : myJSVariable,                            }                 }         }         </script> 

I want to use myJSVariable value in the JSON. Is there a mechanism which tells magento to execute JS instead of treating this as a string ?

Set Link On Admin Menu Grid values in Magento 2

I want to add link in Custom Menu Grid values, so for achieving this I add a class in my layout file and in the class file i do this following

<?php  namespace Feedback\Addon\Ui\Component\Listing\Columns;  use Magento\Framework\View\Element\UiComponentFactory; use Magento\Framework\View\Element\UiComponent\ContextInterface;  class UserEmail extends \Magento\Ui\Component\Listing\Columns\Column {     /**      * Prepare Data Source      *      * @param array $  dataSource      * @return array      */     public function prepareDataSource(array $  dataSource)     {         if (isset($  dataSource['data']['items']))          {             $  fieldName = $  this->getData('email');             foreach ($  dataSource['data']['items'] as & $  item)              {                 if (isset($  item['email']))                  {                     $  path = $  this->context->getUrl('customer/index/edit/',['id'=>244]);                      $  url = "<a = '".$  path."'>".$  item['email']."</a>";                       $  item['email'] = '<a href="'.$  this->context->getUrl('customer/index/edit/',['id' => 224]).'">'.$  item['email'].'</a>';                      $  item[$  name] = html_entity_decode('<a href="'.$  this->urlBuilder->getUrl(self::PRODUCT_URL_PATH_EDIT, ['id' => $  item['product_id']]).'">'.$  item['product_id'].'</a>');                 }             }         }          return $  dataSource;     } } 

it will return the tag not the link, so please tell me what should I do

Fetching order details but items and extension_attributes array are empty

class Index extends \Magento\Backend\App\Action { …… protected $ orderFactory; …… public function __construct( … \Magento\Sales\Api\OrderRepositoryInterface $ orderRespository … ) { parent::__construct($ context); $ this->orderRespository = $ orderRespository; } … public function execute() { $ order=$ this->orderFactory->load(1);

    $  orderItems = $  order->getAllItems();      foreach ($  orderItems as $  item) {     //echo $  item->getProductId();     echo "<pre>";     print_r($  item->getData());     echo "</pre>";     }     exit();   }   return $  resultPage; } 

}

Custom payment method is not showing in checkout Magento 2.2.3

I am new to Magento.I have created a payment method but it is not showing in checkout page. It is showing in Magento Admin Panel.

etc/adminhtml/system.xml

<?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="payment">             <group id="Newpayment" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">                 <label>Newpayment</label>                 <field id="active" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="0">                     <label>Enabled</label>                     <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>                 </field>                 <field id="title" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">                     <label>Title</label>                 </field>                 <field id="int_id" translate="label" type="text" sortOrder="21" showInDefault="1" showInWebsite="1" showInStore="1">                     <label>Merchant ID</label>                 </field>                  <field id="mer_id" translate="label" type="text" sortOrder="22" showInDefault="1" showInWebsite="1" showInStore="1">                     <label>Merchant Settlement ID</label>                 </field>                 <field id="mer_dis_name" translate="label" type="text" sortOrder="23" showInDefault="1" showInWebsite="1" showInStore="1">                     <label>Merchant Display Name</label>                 </field>                 <field id="merchant_priv_key" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="0">                     <label>Merchant Private Key</label>                     <backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model>                 </field>                 <field id="merchant_pub_key" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="0">                     <label>Merchant Public Key</label>                     <backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model>                 </field>                 <field id="api_key" translate="label" type="text" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="0">                     <label>API Key</label>                 </field>                 <field id="debug" translate="label" type="select" sortOrder="85" showInDefault="1" showInWebsite="1" showInStore="0">                     <label>Debug</label>                     <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>                 </field>                 <field id="environment" translate="label" type="select" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="0">                     <label>Environment</label>                     <source_model>Magento\Newpayment\Model\Environment</source_model>                     <config_path>payment/Newpayment/environment</config_path>                 </field>                 <field id="sort_order" translate="label" type="text" sortOrder="160" showInDefault="1" showInWebsite="1"                        showInStore="0">                     <label>Sort Order</label>                     <frontend_class>validate-number</frontend_class>                 </field>             </group>         </section>     </system> </config> 

etc/config.xml

<?xml version="1.0"?>  <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">     <default>         <payment>             <Newpayment>                 <debug>1</debug>                 <active>1</active>                 <model>Magento\Newpayment\Model\Newpayment</model>                 <sandbox_url>https://test.Newpayment.com/pg/pay</sandbox_url>                 <production_url>https://secure.Newpayment.com/pg/pay</production_url>                 <environment>sandbox</environment>                 <merchant_priv_key backend_model="Magento\Config\Model\Config\Backend\Encrypted" />                 <merchant_pub_key backend_model="Magento\Config\Model\Config\Backend\Encrypted" />                 <order_status>pending_payment</order_status>                 <title>Payment method (Newpayment)</title>                 <currency>INR</currency>                 <can_authorize>0</can_authorize>                 <can_capture>1</can_capture>                 <can_void>0</can_void>                 <can_use_checkout>1</can_use_checkout>                 <is_gateway>1</is_gateway>                 <sort_order>1</sort_order>                 <redirect_url>Newpayment/standard/redirect</redirect_url>                 <return_url>Newpayment/standard/response</return_url>                 <cancel_url>Newpayment/standard/cancel</cancel_url>             </Newpayment>         </payment>     </default> </config> 

etc/module.xml

<?xml version="1.0"?>  <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">     <module name="Magento_Newpayment" setup_version="2.0.0">         <sequence>             <module name="Magento_Sales"/>             <module name="Magento_Payment"/>             <module name="Magento_Checkout"/>         </sequence>     </module> </config> 

etc/payment.xml

<?xml version="1.0"?>  <payment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"          xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Payment:etc/payment.xsd">     <methods>         <method name="Newpayment">             <allow_multiple_address>1</allow_multiple_address>         </method>     </methods> </payment> 

view/frontend/layout/checkout_index_index.xml

<?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">     <body>         <referenceBlock name="checkout.root">             <arguments>                 <argument name="jsLayout" xsi:type="array">                     <item name="components" xsi:type="array">                         <item name="checkout" xsi:type="array">                             <item name="children" xsi:type="array">                                 <item name="steps" xsi:type="array">                                     <item name="children" xsi:type="array">                                         <item name="billing-step" xsi:type="array">                                             <item name="component" xsi:type="string">uiComponent</item>                                             <item name="children" xsi:type="array">                                                 <item name="payment" xsi:type="array">                                                     <item name="children" xsi:type="array">                                                         <item name="renders" xsi:type="array">                                                             <!-- merge payment method renders here -->                                                             <item name="children" xsi:type="array">                                                                 <item name="Newpayment" xsi:type="array">                                                                     <item name="component" xsi:type="string">Magento_Newpayment/js/view/payment/Newpayment</item>                                                                     <item name="methods" xsi:type="array">                                                                         <item name="Newpayment" xsi:type="array">                                                                             <item name="isBillingAddressRequired" xsi:type="boolean">true</item>                                                                         </item>                                                                     </item>                                                                 </item>                                                             </item>                                                         </item>                                                     </item>                                                 </item>                                             </item>                                         </item>                                     </item>                                 </item>                             </item>                         </item>                     </item>                 </argument>             </arguments>         </referenceBlock>     </body> </page> 

view/frontend/web/js/view/payment/method-render/Newpayment.js

define(         [             'Magento_Checkout/js/view/payment/default',             'Magento_Newpayment/js/action/set-payment-method',         ],         function (Component,setPaymentMethod) {             'use strict';              return Component.extend({                 defaults: {                     template: 'Magento_Newpayment/payment/form',                 },                 redirectAfterPlaceOrder: false,                  afterPlaceOrder: function(){                     setPaymentMethod();                 }             });         }     ); 

view/frontend/web/js/view/payment/Newpayment.js

define(     [         'uiComponent',         'Magento_Checkout/js/model/payment/renderer-list'     ],     function (         Component,         rendererList     ) {         'use strict';         rendererList.push(             {                 type: 'Newpayment',                 component: 'Magento_Newpayment/js/view/payment/method-renderer/Newpayment'             }         );         return Component.extend({});     } ); 

view/frontend/web/template/payment/form.html

<div class="payment-method" data-bind="css: {'_active': (getCode() == isChecked())}">     <div class="payment-method-title field choice">         <input type="radio"                name="payment[method]"                class="radio"                data-bind="attr: {'id': getCode()}, value: getCode(), checked: isChecked, click: selectPaymentMethod, visible: isRadioButtonVisible()"/>         <label class="label" data-bind="attr: {'for': getCode()}">             <span data-bind="text: getTitle()"></span>         </label>     </div>      <div class="payment-method-content">         <!-- ko foreach: getRegion('messages') -->         <!-- ko template: getTemplate() --><!-- /ko -->         <!--/ko-->         <div class="payment-method-billing-address">             <!-- ko foreach: $  parent.getRegion(getBillingAddressFormName()) -->             <!-- ko template: getTemplate() --><!-- /ko -->             <!--/ko-->         </div>         <div class="checkout-agreements-block">             <!-- ko foreach: $  parent.getRegion('before-place-order') -->             <!-- ko template: getTemplate() --><!-- /ko -->             <!--/ko-->         </div>          <div class="actions-toolbar">             <div class="primary">                 <button class="action primary checkout"                         type="submit"                         data-bind="                         click: placeOrder,                         attr: {title: $  t('Place Order')},                         enable: (getCode() == isChecked())                         " disabled>                     <span data-bind="i18n: 'Continue'"></span>                 </button>             </div>         </div>     </div> </div> 

registration.php

<?php  \Magento\Framework\Component\ComponentRegistrar::register(     \Magento\Framework\Component\ComponentRegistrar::MODULE,     'Magento_Newpayment',     __DIR__ ); 

How to set fixed price for attribute with Magmi in Magento 2

I tried to set different price to some specific sizes of my product. I am using Magento v2.27 and Magmi v0.7.23-git. On the super_attribute_pricing column, I filled size::L:15:0;XL:15:0;XXL:15:0 in the configurable product line. I want to add a fixed price $ 15 for Size L, XL and XXL. But I got an error: SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘broybuy0_mage.catalog_product_super_attribute_pricing’ doesn’t exist – Please advise. Thank you in advance.

Can’t create Magento\Cms\Model\Wysiwyg\Config instance in Magento 2.3

I am working with Magento 2.3. But everytime i try to create instance of Magento\Cms\Model\Wysiwyg\Config by ObjectManager , i meet this error

Exception #0 (BadMethodCallException): Missing required argument $ variablePluginConfigProvider of Magento\Cms\Model\Wysiwyg\CompositeConfigProvider.

Did anyone meet and resolve this one ?

Get Out of Stock products to show in magento 2.3

I’m trying to get options which are out of stock to be passed to the frontend js renderer.

However I’ve found that getJsonConfig() does not return attribute data (attribute labels and other data) for the options array that I pass it.

// I have found that the configurable $  options data is initially set here // I have made it so that this returns the entire array of attribute codes and product numbers - //  - for the configurable regardless of stock status  /* @var \Magento\ConfigurableProduct\Helper\Data $  this->$  helper */ $  options = $  this->helper->getOptions($  currentProduct, $  this->getAllowProducts()); 

Note that the $ options[array] correctly contains all out of stock attribute ids => product ids

$  options array

This $ options array is passed to a function that attempts to serialize/add extra data that is required buy the js renderer such as labels.

$ attributesData = $ this->configurableAttributeData->getAttributesData($ currentProduct, $ options);

/**      * Get product attributes      *      * @param Product $  product      * @param array $  options      * @return array      */     public function getAttributesData(Product $  product, array $  options = [])     {         $  defaultValues = [];         $  attributes = [];         $  productInstance = $  product->getTypeInstance();         $  productEnabledAttributes = $  productInstance ->getConfigurableAttributes($  product);         foreach ($  productEnabledAttributes as $  attribute) {             $  attributeOptionsData = $  this->getAttributeOptionsData($  attribute, $  options);             if ($  attributeOptionsData) {                 $  productAttribute = $  attribute->getProductAttribute();                 $  attributeId = $  productAttribute->getId();                 $  attributes[$  attributeId] = [                     'id' => $  attributeId,                     'code' => $  productAttribute->getAttributeCode(),                     'label' => $  productAttribute->getStoreLabel($  product->getStoreId()),                     'options' => $  attributeOptionsData,                     'position' => $  attribute->getPosition(),                 ];                 $  defaultValues[$  attributeId] = $  this->getAttributeConfigValue($  attributeId, $  product);             }         }         return [             'attributes' => $  attributes,             'defaultValues' => $  defaultValues,         ];     } 

However getAttributesData does not obey the $ options param. A sub call function must unwittingly run a filter operation. Observe below how the return $ attributesData has filtered attribute “138”

data filtered

From the getAttributesData() function, I’m suspecting getConfigurableAttributes() to be the cause of out of stock options not displaying in magento 2.3, this function retrieves data from a cache that was generated a few clock cycles ago.

/**      * Retrieve configurable attributes data      *      * @param  \Magento\Catalog\Model\Product $  product      * @return \Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute[]      */     public function getConfigurableAttributes($  product)     {         \Magento\Framework\Profiler::start(             'CONFIGURABLE:' . __METHOD__,             ['group' => 'CONFIGURABLE', 'method' => __METHOD__]         );         if (!$  product->hasData($  this->_configurableAttributes)) {             $  configurableAttributes = $  this->getConfigurableAttributeCollection($  product);             $  this->extensionAttributesJoinProcessor->process($  configurableAttributes);             $  configurableAttributes->orderByPosition()->load();             $  product->setData($  this->_configurableAttributes, $  configurableAttributes);         }         \Magento\Framework\Profiler::stop('CONFIGURABLE:' . __METHOD__);         return $  product->getData($  this->_configurableAttributes);     } 

Here’s a stack trace to help show where I’m up to.

image