Questions tagged [script]
The script tag has no usage guidance.
185
questions
23
votes
5
answers
30k
views
How can I programmatically flush Magento's Cache?
I'm automating release configurations by bootstrapping Mage in several release scripts. At the end of the scripts, I need to flush Magento's cache.
Is there a way to flush the cache using one of the ...
13
votes
3
answers
10k
views
How to delete unused images from my media folder?
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 a ...
11
votes
4
answers
35k
views
How do I run php custom script on magento2
I wanted to add custom php script to magento2 root folder and run from the browser.I tried to add it in magento2 root folder but it redirects to 404 page.
I also tried to add it in pub folder but no ...
10
votes
5
answers
32k
views
How to get base secure url without index.php
I want to to get base-secure-url without index.php.
I enabled index.php for some reason. Now I have a PHP file at Magento root directory, and I want to call Magento secure pages from this PHP file.
...
8
votes
4
answers
12k
views
Need to Initialization js after ajax response magento 2
I am working on ajaxscroll product but when i got response below script not initialize
<script type="text/x-magento-init">
{
"[data-role=tocart-form], .form.map.checkout": {...
8
votes
2
answers
8k
views
update category attributes programmatically
I can't seem to figure out how to best update hundreds of category attributes with a script. Any suggestions as the best way to approach this? I won't be using the installer or anything like that.
6
votes
1
answer
6k
views
Magento2 <script type="text/x-magento-init"> after ajax
Lets say I want to get ajax response containing everything that is inside #maincontent selector on catalog/product/view/id/1 page.
The problem is that many JS (that works on product view page) doesn'...
6
votes
1
answer
4k
views
update product programmatically magento 2
Whats wrong in my following code ? I am using a script to insert and update product details using csv. Products are inserting / updating without any issues. But only after updated a product...
I ...
4
votes
1
answer
1k
views
What is the effect of Mage::getStore()->setId(Mage_Core_Model_App::ADMIN_STORE_ID)
I've found the following line of code used in some of our one-off scripts, and have also found it used in various unofficial (i.e. not entirely trustworthy) websites:
Mage::app()->getStore()->...
4
votes
2
answers
97
views
What is the best way to versoining in install/ upgrade scripts?
Sometimes I use any of the following mentioned names to name the install/upgrade scripts in custom modules.
install-0.1.0.0.php
upgrade-0.1.0.0-0.1.1.0.php
upgrade-0.1.1.0-0.1.2.0.php
--------------...
4
votes
4
answers
4k
views
Re-save all products in Magento2 - Weird error has forced me to manually resave products to get configurable options to show up on frontend
I can't find any information on how to programmatically re-save all products.
I'm running into a weird error that suddenly all products with configurable options, the options no longer show up on the ...
3
votes
2
answers
11k
views
How to add a JS script after full loading checkout page?
Since the DOM on the checkout page is loaded in an asynchronous way - I do not have access to some elements. Please suggest me how we can add a custom script to the checkout page after loading all the ...
3
votes
4
answers
3k
views
Exclude particular <script> tag moving to bottom of the page- Magento 2.3
In my Magento site, we found there was configuration in admin.
Admin -> Store -> Configuration -> Advanced -> Developer (Enabled only on Developer mode).
JavaScript settings -> Move JS code to the ...
3
votes
2
answers
3k
views
How do I get connection to database by entering Database details in Magento 2?
I want to get custom database connection by adding database details in my custom script without using ResourceConnection.
In Magento 1 we can do like this
$conn = new \mysqli($servername, $username, ...
3
votes
3
answers
2k
views
Export simple product using script in magento2 [closed]
How we get simple product collection with visibility 4 (catalog/search) with script in Magento 2?
3
votes
1
answer
1k
views
Programmatically create a Smart Category Rules
I was following this guide from inchoo for programmatically creating 50+ categories, but then I discovered this Enterprise feature, “Smart Category Rules”, and would like to use this approach instead. ...
3
votes
1
answer
2k
views
Why can't I reinstall Module Magento?
I have a module in magento, and the script setup module. Now I want to re-run this script and this module.
I deleted the setup of this module in core_resource, and access magento. But the module is ...
3
votes
1
answer
5k
views
How to generate an adminhtml page secret key
I'd like to generate a link to an adminhtml page from within a script in my html directory.
I have read this question on Stackoverflow: Magento: generating url for a backend action (with key)
This ...
3
votes
1
answer
2k
views
How to run external script outside of magento 2 root directory?
I have made a few external php scripts to update quantity and tracking numbers,etc Right now, i'm putting them in magento root and set the permission to 640. However, it's still accessible by the ...
2
votes
2
answers
14k
views
How to save customer attribute value in custom script in Magento 2
How to save customer attribute value in custom script in Magento 2.
The prerequisite is to add first your new attribute programatically.
To do add a customer attribute please review these:
Magento2 ...
2
votes
2
answers
4k
views
Creating and placing a widget through install script
Can I create a widget instance and assign it to a specific page to appear through install script? I'd like to have some functionality similar to sample contents, but with widgets. To be more specific, ...
2
votes
3
answers
4k
views
Attempting to pass access keys into composer create-project for automated install
I am writing a shell script in bash (rewriting) that migrates / deploys our magento2 marketplace.
I started off by getting the latest release from github, but that makes it so i cannot use the admin-...
2
votes
2
answers
8k
views
magento 2 Programmatically create a credit memo by script [duplicate]
Given an order that has been invoiced (by cash on delivery for testing) and is in state "processing", how can I create a credit memo?
in code that is outside of Magento routing
EDIT:
I have found ...
2
votes
4
answers
4k
views
How do I run custom script from magento2 root folder?
Below url throwing Class customScript does not exist error. my test.php and customScript.php are in test folder.
Once i run http://127.0.0.1/magento2/test.php, getting "Class customScript does not ...
2
votes
2
answers
3k
views
Collection of all configurable products (which has children)
What is the best way to Collection of all configurable products (which has children) with sku using script?
How to do that?
2
votes
4
answers
2k
views
Filter magento Orders by From & To Date in custom page
magento site : www.1234.com
we are displaying all the orders in page : www.1234.com/php/site6/date.php , user can able to see all orders only when user login to date.php page.
in date.php page, ...
2
votes
2
answers
1k
views
Magento 2 - create custom script on root directory
In Magento 1.9 I simply use below code and Magento's Mage model could be run on the script then
include_once 'App.php';
include_once __DIR__.'/../app/Mage.php';
How can I do it in Magento 2? So that ...
2
votes
2
answers
172
views
How to securely run PHP scripts in Magento 2
I know that we can run php scripts by placing our script in root of magento 2 folder and we can load products, orders etc via object manager and perform our desired functionality. although this method ...
2
votes
2
answers
3k
views
How do I get the ID of a dropdown attribute by its text label?
I have a product attribute which is configured to be a dropdown with a fixed list of available values.
Now I need to write a script which will filter based on the selected value of the dropdown ...
2
votes
1
answer
4k
views
How best to call a custom long running PHP program over and over
I wrote a PHP cli program that I call many times in a loop, each loop processing a set number of rows at one time until there is no more data.
It is a custom REST program that is the middle piece ...
2
votes
2
answers
1k
views
How to remove modal.js and its related files
I need to remove modal.js and it's related files all over the website. It is available in vendor directory and I need to remove it from DOM.
I found similar question, but no one answered it:
How to ...
2
votes
1
answer
2k
views
Magento 2 Inline translate for script strings
I had spent more than 3 hours, but did not find solution.
If subscribe field on home page empty we will get JS message 'This is a required field.' How it may be translated by inline translate (using ...
2
votes
1
answer
977
views
add to cart products with max qty of products error with run script
add to cart products with max qty of products with below code
include 'app/Mage.php';
Mage::app();
Mage::getSingleton('core/session', array('name' => 'frontend'));
// Need for start the session
...
2
votes
1
answer
83
views
Problem with 'poorly written script', causing high server resource consumption [closed]
I have had my magento store and admin taken offline by my server host (siteground) due to excessive consumption of shared server resources. They told me it was due to a poorly written script which was ...
2
votes
1
answer
973
views
How to handle dynamic data in a script tag in head section for every page
I am absolutely new to Magento 2 (1 week in). I am trying to develop a Magento module that lets the admin specify a string (token) and when the admin saves the module I would like the token to ...
2
votes
1
answer
1k
views
Element 'script', attribute 'crossorigin': The attribute 'crossorigin' is not allowed
After installing customer attribute extension from Bsscommerce they added another addon module. It then broke frontend of site so they disabled all of their modules but the error still persists. I've ...
2
votes
1
answer
80
views
Prevent Magento2 display information on script on homepage
I would like to know how can i stop magento2 to printing information about my plugin and script on homepage.If u analyze my code i have got all these script that contain information about all plugin i ...
2
votes
1
answer
930
views
How to remove malicious code from the each files of the website magento 2?
I am seeing some malicious code in the website. Each files of every folder is affected by this code. How to remove this code from the website?
Is any script to remove or replace this malicious code?
...
2
votes
1
answer
2k
views
How do I run PHP script after 5 minutes to prevent server and mySQL limit [closed]
I have written PHP script to upload 1000 products in magento .
But here is the problem .Script only run for 40 seconds and upload 4 or 5 products and then it mySQL time out .
So my server does not ...
2
votes
2
answers
2k
views
Using CURL to call controller action
I am generating an excel report which takes around 10-25mins based on user selection. Page is served to admins only.
When user presses export button after selecting filters, I am trying to call ...
2
votes
0
answers
32
views
Magento2 URL key for specified store already exists. while creating product
I'm creating products using scripts.
Product data came from json file.
Problem is I'm getting error URL key for specified store already
exists. ,when second product has same name but different sku.
So,...
2
votes
0
answers
128
views
why deployVeniaSampleData.sh runs out of memory
Trying to run the Venia sample data deploy script
bash deployVeniaSampleData.sh --yes
but keeps getting
mmap() failed: [12] Cannot allocate memory
PHP Fatal error: Out of memory (allocated ...
2
votes
0
answers
1k
views
Magento 2 import customer script
Does anyone have a script for importing custom customer list form a csv or xml ?
i found the next script for magento 1: https://gist.github.com/peterjaap/5955852, but for magento 2 i can't find ...
2
votes
1
answer
385
views
How do I execute Magento 2 CLI commands using a custom script?
I had created a custom script which update my database. After completion of database update, I want to execute the Magento CLI commands by adding custom functions in my custom script.
The script ...
1
vote
3
answers
5k
views
Magento 2 : Add custom script just after body tag
I am using Magento 2.3
Can anyone please provide appropriate way for
How can i add my custom script code after the tag.
Thanks
1
vote
2
answers
9k
views
Uncaught ReferenceError: jQuery is not defined
we are using 1.9.0
we are trying to save the quantity in frontend, but its not working. we doubt it may be issue with jquery errors present in console.
we wrote phtml code first and script in bottom ...
1
vote
2
answers
503
views
Running a script only one time
I want to remove an attribute from its attribute set, programmatically.
I have this code:
Mage::getModel('catalog/product_attribute_set_api')
->attributeRemove($attributeId, $attributeSetId);
...
1
vote
2
answers
2k
views
Install script of module not running
config.xml:
<config>
<modules>
<ASD_MyhProductImporter>
<version>0.0.1</version>
</ASD_MyhProductImporter>
</modules>
<...
1
vote
2
answers
2k
views
php - create csv export file, based on product values
I currently have the following script, that change the producttitle of a product with a specific ID.
Now I want to re-write the script, so that it does not update the attributes but generates a .csv ...
1
vote
1
answer
987
views
How to populate one column in a table from another table column [Magento OOP way]
I am new to magento. I have to perform a db task in magento upgrade script which should be done using magento OOP db way. But i cannot figure it out how to do it. I can do it in plain sql query but ...