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 ...
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, ...
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 <...
3
votes
2answers
5k 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; $...
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 ...
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 ...
7
votes
2answers
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 ...
4
votes
2answers
5k 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 ...
7
votes
5answers
20k 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, ...
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. ...
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 ...
5
votes
8answers
12k 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 (...
3
votes
3answers
5k 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. ...
6
votes
1answer
3k 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 ...
5
votes
3answers
10k 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 ...
3
votes
1answer
2k 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 ...
0
votes
2answers
7k 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 ...
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'...
15
votes
1answer
15k views

Magento 2 : Add Product Attribute Programmatically

How to create Magento 2 Product Attribute Programmatically with type : Text Area.
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 ...
1
vote
0answers
269 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.
2
votes
5answers
5k 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->...
3
votes
2answers
3k 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 ...
7
votes
5answers
27k 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 ...
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 ...
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 ...
4
votes
4answers
16k 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 ...
4
votes
3answers
3k 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('...
3
votes
1answer
1k 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 ...
3
votes
2answers
2k 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 ...
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
4
votes
2answers
9k 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?
2
votes
4answers
5k 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) ->...
0
votes
3answers
3k 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 / ...
5
votes
3answers
10k 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 ...
2
votes
1answer
7k 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 ...
2
votes
2answers
4k 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 ...
1
vote
1answer
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 ...
1
vote
1answer
291 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-...
1
vote
3answers
10k 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 ...
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 ...
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. ...
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 ...
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:...
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 */ $...
7
votes
10answers
28k views

Magento Redirects to Old Website regardless of what changes are made!

We are having the strangest Redirection problem on a Magento site. We copied the sites contents from another Magento site to a new URL. We have done this in the past with no problems but for some ...
5
votes
5answers
1k views

Magento Hacked: displays list of user emails and error message

-My client suspects his site was hacked,I'm not sure, but when I open index.php I get a list of emails and usernames, and what appears to be encrypted passwords (please correct me if I'm wrong). I ...
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 ...
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 ...