22
votes
Accepted
Magento2 : user define customer attribute not save value while create / save from admin
looks like the issue was due to the fact your attributes are not assigned to the customer attribute set.
the following code is needed in your install: I added full code for you at https://bitbucket....
- 7,530
17
votes
Accepted
How to save customer attribute value in custom script in Magento 2
This is how it can be done with customer save method:
/** @var \Magento\Customer\Model\CustomerFactory $customerFactory */
/** @var \Magento\Customer\Model\Customer $customer */
/** @var \Magento\...
- 3,334
17
votes
Accepted
Insert multiple rows without calling model save inside loop
Use insertMultiple function of class Magento\Framework\App\ResourceConnection
protected $connection;
protected $resource;
public function __construct(
...
\Magento\Framework\App\...
- 22.2k
15
votes
Accepted
How to create a productrepository using object manager in Magento 2?
No. Noooo. Not the right approach.
You haven't given much information about exactly what problem you are trying to solve, but you should never be loading or saving any model directly in a template.
...
- 12.1k
14
votes
New product attributes value cannot be saved in magento 2
What I did to get this working was (Magento 2.3.2):
Mark the product attribute as required setting "Values required" to "YES"
Go to a product, add the attribute, select a value and save
If you need ...
- 243
12
votes
Accepted
Programatically update a single attribute in Store View Scope
Load is pretty expensive memory wise.
You can use this for a faster update:
Mage::getSingleton('catalog/product_action')->updateAttributes(
array($productId),
array('name' => $...
- 197k
12
votes
Accepted
Magento 2: How to Insert Multiple Records to custom table?
We forgot to unset data model after saving.
$productModel->save();
$productModel->unsetData();
[EDIT]
Using model Factory can solve our issue. For example, inject Company\Module\Model\...
- 31.5k
9
votes
Magento 2 Fail to save the value of a newly added Yes/No customer attribute
I found the answer finally.
adding:
$attributeMyhkt->addData([
'attribute_set_id' => 1,
'attribute_group_id' => 1
]);
below:
$attribute->...
- 2,154
9
votes
Accepted
Magento 2 : Could not save admin form contents into the DB
Add the following code in your execute function of Save Controller (Module/Controller/Adminhtml/Example/Save.php)
public function execute()
{
$resultRedirect = $this->...
- 2,643
6
votes
Programatically update a single attribute in Store View Scope
Found it! Thanks to https://magento.stackexchange.com/a/90342/4090
$_product = Mage::getModel('catalog/product')->setStoreId($storeId)->load($productId);
$_product->setName($...
- 1,131
6
votes
Accepted
Magento 1.9.2.4 - SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '0' for key 'PRIMARY' while saving categories
You have an issue in magento log tables.
first Take backup of below tables
log_customer
log_visitor
log_visitor_info
log_url
log_url_info
log_quote
Then truncate the tables.
This will resolved ...
- 76.5k
6
votes
Accepted
How do you get the new product ID after programmatically creating the product?
Okay, here's the situation: Because of how the product save works, $this->_productRepository->save($newProduct); does not reflect changes back onto your $newProduct. It's actually creating a new ...
- 12.1k
5
votes
magento 2 - How to create new object Product?
It is recommended to use dependency injection rather than directly using object Manager. Example: In your controller file you can use following code :
protected $_product;
public function ...
- 8,773
5
votes
How to save the PDF file into Magento root folder
This
$this->_prepareDownloadResponse('invoice'.Mage::getSingleton('core/date')->date('Y-m-d_H-i-s'). '.pdf', $pdf->render(), 'application/pdf');
would send it to the browser. The below ...
- 11.3k
5
votes
Magento Enterprise Slow Product Save (/w and /wo Solr Integration)
I'm running into this issue while upgrading from EE 1.13.0.2 to 1.14.1.0 right now. We experience this when bulk updating product attributes and stock in cronjobs. In 1.13, the jobs take ~3 seconds ...
- 7,677
5
votes
Accepted
Magento 2 : Use aftersave and beforesave method
you can used _beforeSave and _afterSave in your ResourceModel
<?php
namespace Spacename\Modulename\Model\ResourceModel;
class Test extends \Magento\Framework\Model\ResourceModel\Db\...
- 32.3k
5
votes
Accepted
Avoiding save in a loop in mass action
In that case you have to save() your entities, so you'll definitely have to call that method.
The native core Magento file you linked is not the only one that does that, especially the mass actions ...
5
votes
Accepted
Difference between catalog_product_prepare_save and catalog_product_save_before
catalog_product_save_before is one of standard events called by the Mage_Core_Model_Abstract class in its _beforeSave() method. The line looks like this:
Mage::dispatchEvent($this->_eventPrefix.'...
- 5,838
5
votes
Accepted
Magento2. More information about the Entity Manager?
It's not recommended to use EntityManager and its infrastructure for your entities persistence.
In the nearest future, new Persistence Entity Manager would be released which will cover all the ...
- 20.5k
5
votes
How to solve the error : "Could not save product "20072" with position 0 to category 7" in magento 2
To fix this issue i created a custom module.
https://github.com/khasru/magento2UrlRewritebug
Hope it helps.
- 76
4
votes
Product stock is not saved when creating a product programmatically
This is a working example wich i use:
$product = Mage::getModel('catalog/product');
$product->setWebsiteIds(array(1));
$product->setTypeId('simple');
...
- 131
4
votes
How to create Magento editable grid?
Here is a tutorial
http://www.atwix.com/magento/inline-editing-in-magento-backend-grids/
It suggests you override the column renderers
Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Input
to ...
- 375
4
votes
magento 2 - How to create new object Product?
This is a very old question, but the selected answer is completly wrong.
The answer from Manashvi Birla is kind of good but it has 2 problems
He says he is using factory but infact he is not
A ...
- 300
4
votes
Magento admin custom form with multiple entry
You can create a function in one of your javascript files like this:
function savePackage(){
disableElements('save');
if (editForm.submit() == false){
enableElements('save');
}
...
- 197k
4
votes
Accepted
Can't PUT customer in Rest Api Magento2 - fails to complete
if you look at the documentation you'll find that actually the email is not optional so is needed in order to update the customer
customer-data-customer-interface {
id (integer, optional): Customer ...
- 510
4
votes
Magento2: Category Select Attribute Not Saving?
Have you checked if your Custom Category Attribute has actually been added to the database because if it hasn't you should update your version number in the module.xml and run setup:upgrade
Example ...
- 1,881
4
votes
Category with 20000 product not save
It could be an indexer going berserk. Are your indexers set on 'update on save' or 'update on schedule'. When they're set to 'update on save' try switching them to 'update on schedule'. Otherwise ...
- 12k
4
votes
Accepted
Magento 2 - Sales Orders afterSave plugin not working
Try this:
public function afterSave(\Magento\Sales\Api\OrderRepositoryInterface $orderRepo, $order)
{
//Insert into database
$ordersModel = $this->objectManager->create('...
- 1,293
4
votes
Accepted
Magento 2.2.2 On product save i get error ''Invalid Form Key. Please refresh the page'
This problem is occurred after adding more custom options and categories in the product so because php.ini file not allowed to add more custom options.
So, we need to change default settings of php....
- 1,653
4
votes
Added a product as configurable but is is showing as simple? Can I change it?
The product is Configurable only if it has children, otherwise, it is "converted" into a Simple product.
vendor/magento/module-configurable-product/Model/Product/TypeTransitionManager/Plugin/...
- 3,874
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
save × 225magento2 × 105
product × 49
magento-1.9 × 35
database × 16
model × 15
category × 11
adminform × 11
customer × 10
backend × 10
attributes × 9
magento-2.1 × 8
admin × 8
configurable-product × 8
event-observer × 8
product-attribute × 8
adminhtml × 8
magento2.3 × 7
orders × 7
controllers × 7
module × 6
error × 6
sales-order × 6
uicomponent × 6
products × 6