A message from our CEO about the future of Stack Overflow and Stack Exchange. Read now.

New answers tagged

0

Magento2 - How to stop a product from getting added to cart programmatically? Let me know if this answer Is helpful....! Thanks


1

Stores > Settings > Configuration -> General -> Web -> Default Cookie Settings By default, the cookie lifetime is set to 3600 seconds, or one hour. If there is no keyboard activity during that time, the current session ends, and customers must log back into their accounts to continue shopping. You interested in Session Cookie, but if customer session ...


1

try out the below code. <?php namespace XX\XX\Controller\Adminhtml\Index; use Magento\Customer\Api\Data\GroupInterfaceFactory as GroupFactory; use Magento\Customer\Api\GroupRepositoryInterface as GroupRepository; class SaveNewCustomerGroup extends \Magento\Backend\App\Action { protected $_resource; protected $_productRepository; protected $...


0

The CMS Page helper is for pages defined within the CMS module itself in the backend. That is the pageID you are referring to is actually the page_id column within the database that Magento will look up to load data from. If you just want to redirect the customer to their account page, it would be to redirect them to the appropriate page. Something similar ...


0

You can also do it programmatically. But if you need solution for SQL then you can use commands like these: UPDATE sales_order o INNER JOIN sales_order_address oa ON o.entity_id=oa.parent_id INNER JOIN customer_entity c ON oa.email=c.email SET o.customer_id = c.email, o.customer_is_guest = 0 WHERE oa.address_type='shipping' AND c.email = {YOUR CUSTOMER ...


1

Get Customer Attribute values by Group and Customer Id Create Helper file Data.php Path: {VendorName}/{ModuleName}/Helper/Data.php <?php namespace {VendorName}\{ModuleName}\Helper; class Data extends \Magento\Framework\App\Helper\AbstractHelper { public function __construct( \Magento\Framework\App\Helper\Context $context, \...


1

Create Block file in module Customer.php Path : App\Code\{CompanyName}\{ModuleName}\Block\Bookseller\ <?php namespace {CompanyName}\{ModuleName}\Block\Bookseller; class Customer extends \Magento\Framework\View\Element\Template { protected $_customerGroup; protected $_customerFactory; public function __construct( \Magento\Backend\...


0

In body you've to sent data like the following below. { "customer": { "email": "abc@testmail.com", "firstname": "your first name", "lastname": "your last name", "store_id": 1, "addresses": [ { "firstname": "your first name", "lastname": "your last name", "city": "DElhi", "street": [ "...


2

I think it might issue at code. The data for the welcome message section coming from customer-data.In order to understand it, you have to check how Private content worked on Magento 2. Study the links: https://devdocs.magento.com/guides/v2.3/extension-dev-guide/cache/page-caching/private-content.html https://webkul.com/blog/sections-magento-2/ The data ...


0

So You can use the below code in this way. I have mentioned both the ways, so use any one to get customer model public function __construct( \Magento\Customer\Model\Customer $modelCustomer, \Magento\Store\Model\StoreManagerInterface $storeManager ){ $this->modelCustomer = $modelCustomer; $this->storeManager = $storeManager; } public function ...


0

You can load all customer and get customer have wishlist or not currently i have pass one customer have static customer id , you can use that code by all customer $customerId = 1; //Customer Id $wishlistColl = $block->getWishlistByCustId($customerId); if(count($wishlistColl)) { foreach ($wishlistColl as $_item) { echo $_item->getProduct()...


1

I guess that you are trying to return a new attribute (a custom one) via customer GQL query. The below answer is based on that. Below is the sample code of adding a custom attribute to Customer GraphQl query. Module NameSpace : Kcc Module Name : CustomerGraphQl app/code/Kcc/CustomerGraphQl/etc/schema.graphqls type Customer { sample_attribute: String @...


1

To get quote items of a customer please use below code. You can pass customer object also in place of customer id. <?php protected $quoteModel; public function __construct( ... \Magento\Quote\Model\QuoteFactory $quoteFactory, \Magento\Quote\Model\ResourceModel\Quote $quoteModel .... ) { .... $this->quoteFactory = $...


1

Path: Magento22/app/code/Rbj/Training/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="Rbj_Training" setup_version="1.0.2"/> </config> Create UpgradeSchema.php file under Setup folder in ...


1

You can achieve the requirement by creating a module with following steps: Step 1: Create registration.php under app/code/STech/LoginProduct/registration.php with below content: <?php \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::MODULE, 'STech_LoginProduct', __DIR__ ); Step ...


2

Create events.xml file app/code/Vendor/Module/etc/events.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <event name="controller_action_predispatch"> <observer name="...


0

Override the layout catalog_product_view.xml and add a new custom block and phtml file. Create a custom block file and add code for getting customer sessions, if the session exists continue otherwise redirect from it. For adding custom block check that reference Add custom block and for getting customer session check reference Customer Session.


4

i have get the reference URL for your solution... please look at this https://magecomp.com/blog/send-email-to-admin-after-customer-registration-magento-2/ in Your Observer you need to replace setTemplateVars(['post' => $postObject]) with setTemplateVars(['customer' => $postObject]) for send the customer name and email Id to mail. Let me know ...


0

I suggesting you use Solwin Customer Attributes – Extension for Magento 2.Customer Attribute extension will allow you to add new attributes to collect more information on customers and manage them. Refer https://www.solwininfotech.com/product/magento-2-extensions/customer-attributes-magento-2/ for more details.


0

In your custom_form.xml file <field name="your_field_id"> <argument name="data" xsi:type="array"> <item name="options" xsi:type="object">{Vendorname}\{Modulename}\Model\Classname</item> <item name="config" xsi:type="array"> <item name="dataType" xsi:type="string"...


0

Please try this:app/code/Vendor/Module/view/base/ui_component/customer_form.xml <?xml version="1.0" encoding="UTF-8"?> <form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd"> <settings> <collapsible>true</...


Top 50 recent answers are included