blocks – Magento 2.3: How do I retrieve the product price in form.phtml file and assign it to an HTML attribute data-purchase-amount?

How do I retrieve the product price in form.phtml and assign it to an HTML attribute data-purchase-amount ="" as code snippet meant for Klarna tagline placement as seen in the file below.

<div class="product-add-form">
    <form data-product-sku="<?= $block->escapeHtmlAttr($_product->getSku()) ?>"
          action="<?= $block->escapeUrl($block->getSubmitUrl($_product)) ?>" method="post"
          id="product_addtocart_form"<?php if ($_product->getOptions()) :?> enctype="multipart/form-data"<?php endif; ?>>
        <input type="hidden" name="product" value="<?= (int)$_product->getId() ?>" />
        <input type="hidden" name="selected_configurable_option" value="" />
        <input type="hidden" name="related_product" id="related-products-field" value="" />
        <input type="hidden" name="item"  value="<?= (int)$block->getRequest()->getParam('id') ?>" />
        <?= $block->getBlockHtml('formkey') ?>
        <?= $block->getChildHtml('form_top') ?>
        <?php if (!$block->hasOptions()) :?>
            <?= $block->getChildHtml('product_info_form_content') ?>
        <?php else :?>
            <?php if ($_product->isSaleable() && $block->getOptionsContainer() == 'container1') :?>
                <?= $block->getChildChildHtml('options_container') ?>
            <?php endif;?>
        <?php endif; ?>

        <?php if ($_product->isSaleable() && $block->hasOptions() && $block->getOptionsContainer() == 'container2') :?>
            <?= $block->getChildChildHtml('options_container') ?>
        <?php endif;?>
        <?= $block->getChildHtml('form_bottom') ?>
    </form>
</div>
<div class="klarna-placement">
<!-- Placement v2 -->
<klarna-placement
  data-key="credit-promotion-badge"
  data-locale="en-US"
  data-purchase-amount=""
></klarna-placement>
<!-- end Placement -->
</div>

Java – how to get and set the session attribute correctly for multiple variables in the spring boot controller?

I am writing an application that uses Spring boot security and session management with a JDBC. However, I first designed the app under the impression that the Controller was not a singleton. So my controller class was dynamic even if I had read the documents beforehand, I would have realized that it should not be. Although once hosted on a web server, I realized that I had problems with the user session and that I had to read the documentation to better understand it. So now I'm using session management and I'm trying to get all of my variables out of my controller and into my session information in my JDBC. However, I see my car constantly calling Object name = (Object) session.getAttribute() or session.setAttribute("","") in each method where I placed my variables. I am trying to find the best way to call and send data to my session in JDBC.

FYI: I used as 7 global variables in my controller.

Java method:


@RequestMapping(value = "/edit")
    public ModelAndView editPage(@RequestParam(value = "Appcode", required = false, defaultValue = "Appcode") String appcode,HttpSession session) {
        ModelAndView modelAndView = new ModelAndView();
        session.setAttribute("SELECTED_APP",queryService.findDtoById(appcode)); 
        allPlants = queryService.serverWork();

        try {
            OTSApplication selected_app = (OTSApplication) session.getAttribute("SELECTED_APP");
            rc.setProxy();

            if (rc.ValidateUser(id, selected_app.getSys_id()) != 0 || queryService.isAuditor(id)) { 
                gpSelected = apiRunner.runGPData(selected_app.getGuid());
                modelAndView.setViewName("create");
            } else {
                modelAndView.setViewName("forbidden");
            }

        } catch (Exception e) {
            e.printStackTrace();
            modelAndView.setViewName("test");
        }
        modelAndView.addObject("id", id);
        modelAndView.addObject("hasAccess", false);

        return modelAndView;
    }

Variables that must be in session

    private APIRunner apiRunner;
    private Set aryServer = new HashSet();
    private List aryTier = new ArrayList();
    private List hmap = new ArrayList();
    public List mqlSelectorList = new ArrayList();
    private String name, system, mqlList, tag1, tag2, mqlSelector, parseInstruc, myObject, id;
    private String queryWithServerAttached, secondQuery;
    private List allPlants = new ArrayList();
    private static final Logger logger = LoggerFactory.getLogger(OTSController.class);

I know there must be a simple or better standard way to contain these variables and objects in a JDBC session. If I have to, I don't mind, but I don't want to declare a new object Object name = (Object) session.getAttribute() whenever I want to use the field. Please let me know of any other means.

How to get the collection of products from a particular category based on the custom attribute value in magento 2

I have created an attribute for the product like enable / disable to display the product in the frontend cursor. How can I activate the product collection of the product for this attribute value using category ID in magento 2

How to get the collection of products from a particular category based on the custom attribute value in magento 2

I have created an attribute for the product like enable / disable to display the product in the frontend cursor.
How can I activate the product collection of the product for this attribute value using category ID in magento 2

magento2 – Repeat the custom attribute

when i use this method to get custom attributes

$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$_product = $objectManager->get('MagentoCatalogModelProduct')->load($block->getItem()->getProductId());
echo '' . $_product->getData('custom_attribute'). '';

at this location design / fronend / theme / Magento_Checkou / templates / cart / item / default.phtml (page checkout / cart, list products), this method repeats the custom attribute. When a product has no attribute, it takes from the previous product.

magento2 – How to display the product attribute in the Magento 2.3 product list page

How to display the product attribute in the product list page I had used help in Magento_Catalog (Magento_Catalog / templates / product / list.phtml) but it gives the value of the product attribute and not the label of the attribute type is Dropdown.

$this->helper('MagentoCatalogHelperOutput');
$_helper->productAttribute($_product, $_product->getManufacturer(), 'manufacturer');

I went out like 5755

I want to get the value using the above method, how can we do this.

Thanks in advance 🙂

magento2 – How do I get product collections with a filter attribute value in Magento 2?

I'm trying to get a collection of products with a filter by Color attribute (code) with the value Black (5). I have a configurable product in the color Black (5), Red (6).
Here Product name Product 1 (configurable product), Product 1 Black (simple product), Product 1 Red (simple product).

So I receive the resulting black product 1 (simple product) but I want to result from product 1 (configurable product).

So please let me know the code for this.
My code is

$objectManager = MagentoFrameworkAppObjectManager::getInstance();               
$categoryProducts = $objectManager->create('MagentoCatalogModelResourceModelProductCollection');

$categoryProducts->addAttributeToSelect('*')->addAttributeToFilter('color', array('eq' => '5'));
foreach ($categoryProducts as $product) {
    echo "
"; echo $i.'==='.$product->getId().'==='.$product->getName(); echo "
"; //$i++; }

Thanks in advance!

seo – The "UGC" link attribute and my usage context

Google recently advised us to use the following link attributes:

"dofollow" is the default if not specified.

So sponsored is for affiliate links (for example) and "ugc" is "user generated content".

Here's my problem: I have a site with a ton of UGC. I manage a conference directory and each conference organizer downloads a lot of content (around 300 – 500 words) from UGC.

BUT – the content that is downloaded is not a link of course. Is there a way to maybe add this "ugc" tag to a paragraph class or similar?

How do I let Google know that 3 or 4 paragraphs on a page are UGC?

Thank you!

magento2 – Display of the customer attribute in the customer grid

I created the customer attribute in Magneto, but it does not show up in the customer grid, I need to display it without deleting the current attribute. How can I do it.

My code
InstallData.php

namespace SmCutomerNumberAttributeSetup;

use MagentoCustomerModelCustomer;
use MagentoFrameworkSetupModuleContextInterface;
use MagentoFrameworkSetupModuleDataSetupInterface;

class InstallData implements MagentoFrameworkSetupInstallDataInterface
{
    private $eavSetupFactory;

    private $eavConfig;

    private $attributeResource;

    public function __construct(
        MagentoEavSetupEavSetupFactory $eavSetupFactory,
        MagentoEavModelConfig $eavConfig,
        MagentoCustomerModelResourceModelAttribute $attributeResource
    ) {
        $this->eavSetupFactory = $eavSetupFactory;
        $this->eavConfig = $eavConfig;
        $this->attributeResource = $attributeResource;
    }

    public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
    {
        $eavSetup = $this->eavSetupFactory->create(('setup' => $setup));

        $eavSetup->removeAttribute(Customer::ENTITY, "customer_number");

        $attributeSetId = $eavSetup->getDefaultAttributeSetId(Customer::ENTITY);
        $attributeGroupId = $eavSetup->getDefaultAttributeGroupId(Customer::ENTITY);

        $eavSetup->addAttribute(Customer::ENTITY, 'customer_number', (
            // Attribute parameters
            'type' => 'varchar',
            'label' => 'Customer Number',
            'input' => 'text',
            'required' => false,
            'visible' => true,
            'user_defined' => true,
            'sort_order' => 500,
            'position' => 500,
            'system' => 0,
        ));

        $attribute = $this->eavConfig->getAttribute(Customer::ENTITY, 'customer_number');
        $attribute->setData('attribute_set_id', $attributeSetId);
        $attribute->setData('attribute_group_id', $attributeGroupId);

        /*
        //You can use this attribute in the following forms
        adminhtml_checkout
        adminhtml_customer
        adminhtml_customer_address
        customer_account_create
        customer_account_edit
        customer_address_edit
        customer_register_address
        */


        $attribute->setData('used_in_forms', (
            'adminhtml_customer',
            'customer_account_create',
            'customer_account_edit'
        ));

        $this->attributeResource->save($attribute);
    }
}
?>

Thanks in advance 🙂

images – Camera capture tag or attribute in contact form 7

I created a form.
I need to add a field where I need to capture an image using the mobile camera, when the form is opened in the mobile browser. I also need to save this image and its path in a field.
I used the Contact Form 7 plugin and the Contact Form CFDB7 plugin to save the form data.

The following TAG is used and works well (data backup) but this code is to download an existing file, I need a capture attribute.

Download (upload-image file1 file types: jpg | jpeg | png)

Pls help.

Regards,
Shrey