Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

New answers tagged

0

Turns out it was referencing the admin password and not the mysql password. What a fool.


0

Review https://magento.stackexchange.com/a/222428/45214 on how to create a form and save that data in database in magento 2.


0

Create a controller in your Vendor/Modlue/Controller/Index <?php namespace Vendor\Module\Controller\Index; use Magento\Framework\Controller\ResultFactory; use Magento\Framework\App\Action\Context; use Vendor\Module\Model\YourModel; class Blog extends \Magento\Framework\App\Action\Action { protected $model; protected $date; protected $...


0

If you have phpMyAdmin then you can do by going to table and clicking on Operations. After that you see a AUTO_INCREMENT which in my case is 42. You can reset it to 1 and it should solve your problem. If you have command line access only then you can run the below mysql query: ALTER TABLE `catalog_category_entity` AUTO_INCREMENT=1


0

In the end we managed to solve this. However we had to hire an external developer so we are not 100% sure where the reason was but in the end it could be solved by someone with some more knowledge on Magento then I had.


2

How did you create your database? Did you migrate from another server using mysql dump? If so the answer is the view part of the question I asked. Magento 2.3 introduced a view table which causes issue with import of mysql dump. What's it for? think maybe either you are missing the view or the query requiring elevated access in the import interrupted ...


2

If you have model for your custom table then you do all these stuffs in the below way Try this, Di method : Inject your model in your constructor protected function __construct( .... \Vendor\ModuleName\Model\ModelName $customTable, .... ) { ... $this->customTable = $customTable; ... } then on your execute function from controller ...


0

Try this code, $duplicates = DB::table($module) ->select('Name','Phone', DB::raw('COUNT(*) as count') ->groupBy('Name', 'Phone') ->having('count', '>', 1) ->get();


0

Magento uses an EAV table structure for products. Names are stored in catalog_product_entity_varchar. If you have the product ID X, you can query this table directly: SELECT entity_id, value, store_id FROM catalog_product_entity_varchar WHERE entity_id = X AND attribute_id = ( SELECT attribute_id FROM eav_attribute WHERE entity_type_id=4 AND ...


0

Do you want to get the data from the database using rest? Are you using it internally (in the same code/site/environment)? Or you want to get the banners to somewhere externally? If it is the second case, then you have to ask the developers to implement that. If it is the first case, then you should just get the collection. If you want to implement your ...


0

Just create the attribute with the attribute_code you'd want, then go to the eav_attribute table, search for your attribute_code, and change its ID to your desired one. UPDATE eav_attribute set attribute_id = YOUR_ID where attribute_code = 'ATTRIBUTE_CODE' There should not be any problem, magento has foreign keys for eav attributes, the only problem ...


0

I use the Api Service Layer Magento\Eav\Api\AttributeRepositoryInterface suggested by @kandy in comments on @marius answer. Inject the service data member in your constructor as follow. protected $eavAttributeRepository; public function __construct( ... \Magento\Eav\Api\AttributeRepositoryInterface $eavAttributeRepositoryInterface, ... ){ ...


0

Data is duplicated for each store view. Each entity value could and probably will end up with a value for each store. And magento has lots of eav entities which can have values that differ between stores. With this many store views there will be a lot of duplicated data. Indexing will be impacted. Everything will be impacted. I'm in no doubt the store will ...


0

yes database data will grow, but there are no performance penalty in it, you will get some issues only if you have no space to expand/scale. proper infrastructure is a key here. creating a new "website > store > store view" - is correct way. im sure you have database in multi-server environment?


1

In this case, you need to implement extension attribute for Magento\CatalogInventory\Api\Data\StockItemInterface. Use these two fields as extension_attributes on Magento\CatalogInventory\Api\Data\StockItemInterface <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:...


2

Change by following code: <column xsi:type="int" name="id_user" padding="10" unsigned="true" nullable="true" identity="false" comment="User ID"/> Column definition should be same if you use as a foreign key.


1

created Observer which calls Cataloginventory Stock Item Save After event. <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd"> <event name="cataloginventory_stock_item_save_after"> <observer name="Vendor_Module::...


1

refer to this for some more info: https://stackoverflow.com/questions/47022537/magento-2-checkout-missing-postcode check the references to eav_attribute table in the tables mentioned in the answer above and add the indexes that you are missing. for me this was also caused by migration, but not fixable with a backup.


0

I will face the same issue and found the solution first enter in mysql using terminal/cli with below commands mysql -u [db username]_user -p use [db username]_db View runnig processes by following command SHOW PROCESSLIST; Then kill the process in 'command' sleep in my case the process in the first row with id 22023836 KILL 2202836; Then refresh the ...


0

this is easy, first search where you can get a query from search and then just create product with this name , sku etc. and just use this : protected $formKey; protected $cart; protected $product; public function __construct( \Magento\Framework\App\Action\Context $context, \Magento\Framework\Data\Form\FormKey $formKey, \Magento\Checkout\Model\Cart $...


0

To change int value to text you can use below code : <column name="yourcolumn" class="Vendor\Modulename\Ui\Component\Listing\Column\Yourcolumn"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> <item name="filter" xsi:type="string">false</item> <item name="...


0

public function loadWithFilter( $printQuery = false, $logQuery = false ) { // you need to implement this functon $this->getSelect()->reset(\Zend_Db_Select::FROM) ->from( ['maintable' => new \Zend_Db_Expr('(SELECT enroller_id, entity_id FROM customer_grid_flat) customer_grid_flat, (SELECT @pv := "$id") initialisation')],...


0

just add code echo $this->getSelect(); exit; it will print your query


0

there are a magento simple way via admin configuration , if you enable this, you will have this product https://bsscommerce.com/blog/how-to-enable-stock-alert-and-display-out-of-stock-product-in-magento-2/ https://www.magestore.com/magento-2-tutorial/magento-2-displaydisable-out-of-stock-product-by-your-own/ if I right understood ...


0

Unfortunately Magento does not support Postgres, nor is it likely to in the foreseeable future. Besides the extensive core work that would likely be necessary, it would break many third party extensions that use direct SQL queries in the MySQL dialect.


0

I solved the issue with below code added in this path : /vendor/magento/framework/DB/Adapter/Pdo/Mysql.php case 'longtext': if (is_array($value)) { $value = json_encode($value); } $value = (string)$value; if ($column['NULLABLE'] && $value == '') { $value = null; } break;


0

Have a look at: https://github.com/magento/magento2/issues/15545 There are some great suggestions here.


0

I figured it out. I needed to have getEntityId() as a member of MyExtensionInterface so that Magento would know that my row already exists.


0

<?php /* to load the Product */ $_product = $block->getProduct(); $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $attributeSet = $objectManager- >create('Magento\Eav\Api\AttributeSetRepositoryInterface'); $attributeSetRepository = $attributeSet->get($_product->getAttributeSetId()); $_attributeValue = ...


1

Magento is trying to load the product by SKU but you didn't send it in your Json. Even though you are passing the SKU on your URL, SKU is still a required field. , try with: { "product": { "price": 1, "sku": 12345, "extension_attributes": { "stock_item": {"qty": 2} } } } Here in swagger is showing that SKU is required. Follow swagger for your ...


1

Please follow below steps for drop table using db_schema.xml in Magento 2.3.X 1) Disable table First of all, you need to add disabled="true" attribute in your table node. <table name="abcd" resource="default" engine="innodb" comment="Table" disabled="true"> 2) Set blank table node Remove all nodes in between table <table name="abcd" ...


2

Custom action to delete all the rules Try following way: use Magento\CatalogRule\Api\CatalogRuleRepositoryInterface; use Magento\CatalogRule\Model\ResourceModel\Rule\Collection as RuleCollection; use Magento\CatalogRule\Model\ResourceModel\Rule\CollectionFactory as RuleCollectionFactory; Di public function __construct( CatalogRuleRepositoryInterface $...


1

try as below echo $collection->getSelect()->__toString();


0

You can simply bypass this error by checking first in your script if the table exists or not. Something like this: $tableName = $installer->getTable('yourTableName'); if ($installer->getConnection()->isTableExists($tableName) != true) { //your create table script }


1

Here is what I did, I created a relationship id column (like @magefms recommended) which happens to be the primary key, and whenever I need to update this relationship, I delete all the records that contains an specific attribute_id and create it again. To do that I implemented the following function in my model: public function deleteByColumnValue($column, ...


Top 50 recent answers are included