Questions tagged [php]

This tag is used for questions which 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
87
votes
4answers
41k 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/...
70
votes
13answers
28k 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 ...
33
votes
4answers
20k views

Magento 2: Run `setup:di:compile` **only** a Specific Module?

Is it possible to pre-generate code for one specific module? I.E. -- I can generate all the code in the system with php bin/magento setup:di:compile However, this can take a long time. I'd like to ...
26
votes
3answers
4k 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'...
25
votes
12answers
43k 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 ...
24
votes
5answers
11k 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 ...
23
votes
1answer
12k 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 <...
21
votes
7answers
24k 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. ...
21
votes
5answers
2k views

Running Magento 2 via FastCGI (not mod_php) on OS X via brew Packages

Based on various forum postings and conversations in the community, it seems like some folks are running Magento 2 development instances on OS X via a PHP environment that doesn't use the built-in ...
21
votes
4answers
9k 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 ...
20
votes
10answers
27k views

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

Magento 2. After 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, ...
20
votes
2answers
5k 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 ...
19
votes
3answers
3k views

Magento 2: How Should Module Developers Read their Own Configuration Files

Scenario: I am a Magento 2 module developer. I want to create a configuration file in app/etc. I want this file to be "scoped" by area app/etc/my_file.xml app/etc/frontend/my_file.xml app/etc/...
18
votes
7answers
6k views

Magento 2: “Your web server is set up incorrectly and allows unauthorized access to sensitive files. Please contact your hosting provider”

My Magento 2 development environment has started poking me with the following error message Your web server is set up incorrectly and allows unauthorized access to sensitive files. Please contact ...
17
votes
3answers
1k views

What Classes are “Intercept-able/Plugin-able” in Magento 2

Date: May 30, 2015 (given the changing nature of Magento 2). Magento 2 introduced a plugin concept, implemented via an interceptor pattern. What's not clear from the docs is -- which classes and ...
17
votes
3answers
16k 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 ...
16
votes
3answers
27k 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 ...
16
votes
3answers
1k views

What is http://packages.magento.com/?

On various social medias I've seen the URL http://packages.magento.com/ bandied about. This appears to be a composer repository (using satis software to host the repository). What's not clear is ...
16
votes
1answer
2k views

Magento 2: What's the Difference Between the Two Grid Component Data Providers?

In Magento 2.1, there are 25 total UI Component listing/grid data providers configured and in use. Their data provider classes and ui_component files are listed below Magento\Bundle\Ui\DataProvider\...
15
votes
1answer
15k views

Magento 2 : Add Product Attribute Programmatically

How to create Magento 2 Product Attribute Programmatically with type : Text Area.
15
votes
2answers
6k views

Setting up an Admin Route in Magento 2

Looking at the core Magento 2 code, there seems to be two ways of setting up an admin route. The first #File: vendor/magento/module-media-storage/etc/adminhtml/routes.xml <config xmlns:xsi="...
15
votes
1answer
3k views

Magento 2: Why does a UI Listing Component need Two Collections?

Magento 2 has a new "uiComponent" feature. This allows to you to include a simple <uiComponent/> tag in your layout handle XML files to add things like Grids and forms to your application page. ...
14
votes
3answers
5k 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 ...
14
votes
2answers
2k views

How is magento 2 better than magento 1?

I am just curious to know about magento 2 performance and how it is better than magento 1.x versions. Recently I started learning magento 2 and found that it is a whole new set of theory based on pure ...
14
votes
2answers
2k views

What do “#@+” & “#@-” strings mean in the comments?

I see a lot of "#@+" & "#@-" strings in the comments of the some Magento 2 classes. \Magento\Customer\Api\Data\AttributeMetadataInterface interface AttributeMetadataInterface extends \Magento\...
14
votes
2answers
312 views

How to keep .phtml files lean and clean?

As its file extension suggests a .phtml file allows PHP code to be mixed with HTML. However, the fact that you can should not be seen as a license to go wild. Why do we still see so many .phtml ...
14
votes
1answer
671 views

Magento 2: How to show the custom option in another phtml file

How can we override this position in custom option to show it in another phtml file. added this code in checkout_cart_index.xml which override only the form.phtml not override the default.phtml file. ...
13
votes
6answers
9k views

Magento 2: How to show address field in registration form?

I want to display address fields (to save in default billing address) in customer registration form. I know how to do in Magento 1. But I'm struck with Magento 2. Have anybody done this before ..? ...
13
votes
1answer
236 views

Is there a good reason to put the same code in both try AND catch blocks?

In the file: app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Datetime.php, within the render() method, it seems like the exact same code is being run in both the try and catch blocks. ...
12
votes
3answers
4k views

Injecting Dependencies into a Magento 2 CRUD/Abstract Model

Is it possible to inject a dependency into a Magento 2 CRUD model? That is -- Magento 2 has a base abstract model class: Magento\Framework\Model\AbstractModel. If you want to create a simple Create, ...
12
votes
4answers
4k views

Why was get.php and/or `core/file_storage_database` Created?

Since around version 1.5 or 1.6, Magento's had a file in the root folder named get.php. This file, using the core/file_storage_data model, allows Magento system owners to serve their product media ...
12
votes
2answers
8k 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 ...
12
votes
3answers
30k views

Magento new custom block module

I'm using Magento version 1.8.1.0. I'm trying to create a new custom block module, which I'll use for creating a new home page. Namespace: Crusader Module: CLHomePage Block Type: crusaderhome Class:...
11
votes
1answer
344 views

Using Reserved Words in Magento 2 URLs

Is it possible to create a module in Magento 2, using standard routing, that responds to a URL in the form of http://magento.example.com/namespace_module/return/index That is -- a URL where the ...
11
votes
1answer
2k views

What's your way of debugging xml related exceptions?

I'm coding with Magento 2 in gvim and I am new to Magento 2. There were many times i struggled to debug xml-related errors, well, each time with only luck. But situations like this makes me really ...
10
votes
3answers
15k 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 ...
10
votes
1answer
620 views

Magento 2: Virtual Type Naming Convention

Date: June 1, 2015 (given the changing nature of Magento 2) In Magento 2, you can configure a "virtual type" in a module's di.xml configuration file. These virtual types allow you to change the ...
10
votes
4answers
18k 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 */ $...
10
votes
2answers
2k views

How to hide Magento from CMS detectors?

I have a Magento store and I want to hide it from cms detectors. I mean I don't want anyone to know my website CMS and that my website is built on Magento. There are some websites like http://guess....
9
votes
13answers
58k views

Magento 2: 500 Internal Server Error

I followed the Magento dev docs per below: If you add a new .html template, and then edit it, the changes will not apply until you do the following: delete all files in the pub/static/frontend ...
9
votes
3answers
4k views

What are the top useful Phpstorm plugins for Magento 2 development?

What are the list of useful magento2 development tools? What are the top phpstorm useful plugins for magento2 development?
9
votes
2answers
5k 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
9
votes
3answers
514 views

Why Does Magento 2 Force URLs to be 3+ Characters

If you attempt to create a module with a front name like hello-world in Magento 2, you'll get an error that looks like this. Invalid XML in file /Users/alanstorm/Sites/magento-2-with-keys/magento2/...
9
votes
1answer
566 views

Magento OAuth callback url ignored

I was working on a user authentication within an App i'm building. The idea is that I will have customers login via the OAuth of Magento and afterwards it must get the Customer_id of that user. But ...
8
votes
1answer
41k views

Why do I get “SOAP-ERROR: Parsing WSDL: Couldn't find <definitions>”?

I am trying to set up a SOAP client on one server to communicate with Magento on a test server. Both servers have PHP's SOAP extension installed, configured and show up in phpinfo(). Tried turning ...
8
votes
4answers
12k views

Get Price of Configurable Product options

I need to export all products with prices from Magento 1.7. For simple products this is no problem, but for configurable products I have this problem: The price exported is the price set for the ...
8
votes
3answers
1k views

How/Where does Magento Convert a RequireJS module Name into a URL?

In Magento 2, you can use RequireJS to include a javascript module with code that looks something like this. #File: app/code/Package/Name/view/frontend/requirejs-config.js var config = { map: { ...
8
votes
4answers
2k views

Example of Code and Configuration Needed for a Simple Magento 2 CRUD Model?

How can I, an end-user-programmer, create a new "CRUD" model in Magento 2? That is, I want to create the PHP class files and XML configuration files that will Let me Create, Read, Update and Delete ...
8
votes
6answers
7k views

Tools to Scan Magento Code for Malicious Content

We have a client who is very concerned with Malicious code being introduced in third party modules, especially modules that are coming from Magento Connect (Or any free module) They would like to use ...
8
votes
1answer
2k views

Magento 2, How to delete unused images using php script

I have more than 50,000 images in pub/media of products. But there are so many unused images so I want to remove all images which are not associated with any product. For magento 1.9.x this can be ...