Questions tagged [php]

This tag is used for questions that involve PHP code in any way. So as soon there is a PHP Exception returned or error report generated, this question qualifies to be tagged with PHP.

Filter by
Sorted by
Tagged with
105 votes
4 answers
57k views

Explanation of UI Component Grid in Magento 2

Is there a good explaination and/or sample of the bare minimum configuration needed to create a UI Component Grid in Magento 2? I know there are myriad core components, such as ./vendor/magento/...
Alana Storm's user avatar
  • 44.3k
11 votes
7 answers
51k views

Magento 2 - Get Subcategories of Specific Parent Category

What I'd like to do is grab all of the child categories of a specific parent category. I'm assuming the best way to do this is by using the parent's ID and of those child categories that are returned, ...
Paul's user avatar
  • 1,501
72 votes
13 answers
29k views

Is Magento ready for PHP 7?

PHP 7 is reaching beta status and lots of testing is going on at the moment. Given that Magento caught up within the last year from "runs only on PHP 5.3" to "fully compatible with PHP 5.6", I would ...
Fabian Schmengler's user avatar
35 votes
14 answers
59k views

Magento 2 - What is the correct way to change default Order Id?

Magento 2. After a fresh install, the new Order id will be 100000001, 100000002, and so on. What is the correct way to change that increment id so it would be a higher number? For example 155555552, ...
Mark's user avatar
  • 993
25 votes
1 answer
15k views

Magento 2: Adding Arbitrary HTML to the <head> of Every Page?

In Magento 2, is it possible to add an arbitrary bit of HTML to every frontend/cart page's <head/>? I know I can add a block to the content/<body> area with code something like this <...
Alana Storm's user avatar
  • 44.3k
3 votes
2 answers
7k views

Magento 2: Save all product data outside Magento with Images

I have below code with Image Upload which is working fine. But images are not stored in Database Table as mentioned in Order. include('app/bootstrap.php'); use Magento\Framework\App\Bootstrap; $...
Jackson's user avatar
  • 9,889
10 votes
3 answers
20k views

Programmatically create a configurable product and assign the simple product to configurable product in Magento2 product

This is what I've done so far. The simple and configurable products are created. The problem is I cannot assign the simple product to configurable product. Here is the code (ids and attributes works ...
mmmgigi's user avatar
  • 151
21 votes
2 answers
7k views

Magento 2: what is the $data array constructor parameter?

So I noticed that in most models and blocks, there's this array $data = [] given as the last parameter of the constructor. For example \Magento\Catalog\Block\Product\ListProduct public function ...
Raphael at Digital Pianism's user avatar
16 votes
3 answers
28k views

Magento : Fatal error: Class 'Mage_Giftcards_Helper_Data' not found in …/app/Mage.php on line 546

I have installed one module extension which throws an fatal error "Fatal error: Class 'Mage_Giftcards_Helper_Data' not found in ..../app/Mage.php on line 546" in admin. I have reffered this link ...
Mukund Thanki's user avatar
7 votes
2 answers
5k views

Impossible to save category with more that 1000 products

This is a known issue caused by PHP 5.3.9 and max_input_vars that by default it is set to 1000. The solution 2 proposed here it is the best in my opinion but doesn't work: for some strange reason it ...
Fra's user avatar
  • 6,965
4 votes
2 answers
12k views

Share cart in magento 2 multistore

I have a magento 2 website where we want to have 3 different stores on 3 different domains. We want to share cart and customer session on the different websites. Each website/store will have different ...
Arvind07's user avatar
  • 1,229
4 votes
1 answer
4k views

Magento 2: Can you Filter By store_id Using a Product Repository

In Magento 2, it's not possible to add a store_id filter to a product collection directly. Instead, you need to use the addStoreFilter method, which adds a special "product limitation filter". It ...
Alana Storm's user avatar
  • 44.3k
26 votes
4 answers
20k views

Magento 2: Sending Email Programmatically

Does Magento 2 have any built-in integration with third party transaction email deliverability systems like Amazon SES, Mandrill, etc., or is the built-in email functionality still based around PHP's ...
Alana Storm's user avatar
  • 44.3k
22 votes
7 answers
25k views

I am starting out learning Magento with no PHP experience, what are my options?

I have programming experience and HTML experience and am struggling to find a good guide for beginners. The Magento website seems pitched at experts but I could be looking in all the wrong places. ...
peterhartman's user avatar
8 votes
1 answer
7k views

Magento2 :: Accessing $_FILES using Magento Framework [duplicate]

I am current working on a file upload functionality in Magento. Everthing is working great. I am using the \Magento\Framework\File\Uploader and files are getting properly uploaded. The issue I would ...
Atish Goswami's user avatar
6 votes
3 answers
12k views

How to override an admin theme template?

I would like to override app/design/adminhtml/default/default/template/page.phtml i'm currently using an extension that overrides app/design/adminhtml/default/default/template/page/header.phtml with ...
Nxlevel's user avatar
  • 407
5 votes
3 answers
11k views

Magento 2: How to show/hide payment method on basis of amount

I'm using Magento 2 CE Version 2.1.0. I have 2 payment method Paypal Express Checkout & Bank Transfer. When the amount is greater than X then Paypal should not be displayed only Bank Transfer. ...
Jackson's user avatar
  • 9,889
5 votes
8 answers
15k views

How to add hreflang tags (or other meta tags) to pages in magento?

Hi using info from this site and around the web I have started to add hreflang tags to my magento store. They work and display as they should on the default (American)site, however on the alternate (...
user4517's user avatar
  • 353
0 votes
2 answers
8k views

Moving from http to https - redirect via htaccess file

All my urls were unsecured and was indexed by google like that. Now I'm planning to secure all my pages with https But when the old urls show up on google search they automatically resolve to the ...
user2240778's user avatar
30 votes
3 answers
6k views

Creating Integration Tests for Magento 2 Modules

So far for my Magento 2 testing needs, I've been using PHP Unit as (more or less) an acceptance tester -- testing results of server and HTML requests made into a system with my module(s) installed. I'...
Alana Storm's user avatar
  • 44.3k
17 votes
2 answers
23k views

Magento 2 : Add Product Attribute Programmatically

How to create Magento 2 Product Attribute Programmatically with type : Text Area.
user avatar
16 votes
3 answers
27k views

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry - Magento 2

I'm trying to setup my crons for Magento 2.2.2, but nothing seems to be updating. I have created cron in cPanel, like below, each once per minute: /usr/local/bin/php /home/userishere/public_html/bin/...
MyStackExchange's user avatar
14 votes
2 answers
15k views

Magento 2: Product Repositories, Filter Groups, and `AND`

I'm trying to use a product repository to fetch a list of products. I want to fetch based on two filters, combined with an AND criteria, but things don't seem to be working. Do I not understand how ...
Alana Storm's user avatar
  • 44.3k
4 votes
4 answers
18k views

Defer parsing of JavaScript in Magento

i analyzed my website on Gmetrix.com for for optimization and the result was this: 361.0KiB of JavaScript is parsed during initial page load. Defer parsing JavaScript to reduce blocking of page ...
Moh3n's user avatar
  • 859
4 votes
3 answers
5k views

How to copy a product's attributes value to another attribute?

i want to copy a product's attribute (weight) to another atribute (general_weight). i found this codes, but i don't know what to do with this codes? or where to copy them? $prod=Mage::getModel('...
Moh3n's user avatar
  • 859
3 votes
2 answers
7k views

Magento 2 - rewrite checkout and account url

What would be the proper way to rewrite/translate Magento 2 checkout and user account URL's to make them localized for my language? 1. Checkout Current checkout URL's are: domain.com/checkout ...
g5wx's user avatar
  • 681
2 votes
5 answers
10k views

Magento 2 Get Currency Symbol from Currency Code

I have below code $currencyManager = $_objectManager->create('Magento\Directory\Model\CurrencyFactory')->create()->getResource(); echo $currencySymbol = $currencyManager->...
Jackson's user avatar
  • 9,889
1 vote
0 answers
311 views

Patch Installation - Security Patch SUPEE-10415 return 404 error Both Front-End & Back-End

I try to install Security Patch SUPEE-10415, after successfully installed my front-end and back-end getting 404 error.
zus's user avatar
  • 165
1 vote
3 answers
21k views

How to correctly update product programmatically - Magento 2

The Context: By decision of the client, the Magento Administrator cannot add products by himself, all he can do is edit them, therefore the addition of products must be done programmatically. There ...
A. Martz's user avatar
  • 305
0 votes
3 answers
7k views

Magento 2 - add Enable / Disable field for custom module

I want to add some fields in the Magento 2 Admin Panel for my custom module and then I want to check in the phtml file if this field is have value or not. I need to add this fields: - enable / ...
Robert's user avatar
  • 2,166
35 votes
17 answers
102k views

Magento 2 Allowed Memory exhausted error when compile code

I have error when i add module.. Please re-run Magento compile command so i run below command but also display error that below when run command from root, php magento setup:di:compile Compilation ...
Khushbu Mehta's user avatar
29 votes
6 answers
28k views

Magento 2: Programmatically Add a Value to `core_config_data`

Does Magento 2 have a high level abstraction that allows end-user-programmers to update configuration values in the core_config_data table? Or is using straight SQL the only way to do this in Magento ...
Alana Storm's user avatar
  • 44.3k
17 votes
3 answers
19k views

Importing orders from a CSV into Magento programmatically

We're switching from an old, outdated point-of-sale system to using Magento 1.7 as our POS exclusively. Not unexpectedly, one of the challenges we're facing is how to get almost 20 years of records ...
Kale's user avatar
  • 271
16 votes
3 answers
11k views

Magento 2: Syncing Backend and Frontend State/Cache

Does Magento 2 have any systems or abstractions for managing state between the backend and the local storage on the frontend? I'm working on porting a feature for restoring a user's abandoned cart ...
Alana Storm's user avatar
  • 44.3k
12 votes
4 answers
37k views

Magento 2: How to Filter a Product Collection By Store ID

Using a product factory object, I'm able to create a product, grab a product collection, and fetch the first item of that collection /* var $productFactory \Magento\Catalog\Model\ProductFactory */ $...
Alana Storm's user avatar
  • 44.3k
9 votes
2 answers
6k views

Why doesn't Magento 2.1 support PHP 7.0.3 to 7.0.5?

As you may know Magento 2.1.0 is out. According to the release notes, only PHP 7.0.2 AND PHP 7.0.6 are supported Why aren't PHP 7.0.3 / 7.0.4 / 7.0.5 supported ? Edit: 2.1.2 now supports PHP 7.0.4
Raphael at Digital Pianism's user avatar
7 votes
3 answers
20k views

Magento 2: Sending a Custom Header/Response from a Controller

In Magento 2 is it possible, from a controller execute method, to manipulate the request to send a custom header and error page. In Context: We're implementing a small, limited REST API endpoint ...
Alana Storm's user avatar
  • 44.3k
7 votes
5 answers
28k views

programmatically adding product to cart returns empty price

i have been trying to programmatically add a product to cart using following lines of code, it seems to work and successfully adds product but for some reason, the price of newly added product always ...
ehmad11's user avatar
  • 123
5 votes
3 answers
8k views

magento2.2 - programmatically create coupon

in a magento 2.2 based site we need to programmatically create a coupon code for . However was only able to find one code sample and it does not seem to work. Meaning no coupon code is created and ...
Jayreis's user avatar
  • 705
4 votes
2 answers
7k views

Uploading multiple files in custom module does not work in Magento 2

I am new to magento 2. I have been overriding a module in which I am trying to post images through a form. Here is my template file code: <form action="somecontroller.." enctype="multipart/...
CodeGenius's user avatar
4 votes
2 answers
12k views

Get all abandoned carts in Magento

How could I get all the abandoned carts with customer's email (programatically)? What does Magento consider as being abandoned? Not updated in the last day?
Dan Ovidiu Boncut's user avatar
4 votes
1 answer
11k views

Magento2 how to downgrade properly

I had a Magento2 version 2.0.5 and I upgraded it to Magento 2.1.0rc1 using composer. I ran the command for setup upgrade and db schema upgrade. After upgrade I have faced some comparability issues ...
user40778's user avatar
3 votes
3 answers
6k views

Sales : Orders :How to add custom order status programmatically

I need to add custom status for an order programatically I have below controller file to save order status. I need to add custom status as cancel initiated.Provide me a solution... Controller file ...
Jaisa's user avatar
  • 2,606
3 votes
1 answer
2k views

Cron error on line 240 from Mage/Core/Helper/Abstract.php

I will start by saying that I have not overwritten any core files (except the one noted below), and have disabled my theme. I'm am currently running on stock Magento 1.9.1. My website is not live, and ...
SeanM's user avatar
  • 178
3 votes
1 answer
10k views

how to use cookie-free domains in magento? [closed]

I analyzed my website on Gtmetrix.com for optimization and the result was this: There are 245 components that are not cookie-free: http://mysite.com/media/css/dabf35e7cd79eb387a68eed1d5f3f925.css ...
Moh3n's user avatar
  • 859
2 votes
3 answers
5k views

No Inode space!; How to delete Magento sessions folder's contents?

Hopefully, someone can help me, A Magento website I'm managing keeps going down, I've determined it to be the fact that it has used up all of the Inode space on the server. The output to df -i is ...
A. Lal's user avatar
  • 121
2 votes
4 answers
9k views

How to check if a collection has items?

What does a product that is not found return in terms of Object? I'm loading a product like the following: $man_collection = Mage::getModel('catalog/category') ->load($mProduct) ->...
Stefanos's user avatar
  • 231
1 vote
1 answer
2k views

Magento 2.3.0 - Can't login to admin

I can't login to admin panel on Magento 2.3.0 version. After I press Sign In button I have this message: "Invalid Form Key. Please refresh the page." and in the system.log file I have this: [2019-02-...
Robert's user avatar
  • 2,166
1 vote
1 answer
1k views

PDO is required ERROR

I've started getting this error when trying to Access Magento downloader, the rest of the site work: The PDO extension is required for this adapter but the extension is not loaded Been searching ...
Artur Rain's user avatar
1 vote
1 answer
562 views

Magento 1.9 - How to include custom PHP Script into .PHTML file

My magento tracking page: Back-end magento code : How can i add my PHP script into this tracking page. Tracking page code - trackorder.phtml [https://i.stack.imgur.com/ySgMA.png] <?php ...
zus's user avatar
  • 165

1
2 3 4 5 6