texts: Format Phone number before it's saved to the database

texts:
I am looking for a way to make sure when a phone number is added to the database for an order/customer that it is stripped of all non-numeric characters.

I have code to strip the characters and ensure it is all digits/numbers however I am not sure how I can make it hook in and do this right before saving to the database to make sure it gets saved as just numbers.

Any ideas on the best way to do this and how?

$str = '(760) 451-2832';
$phone = preg_replace("/[^a-zA-Z0-9]/", "", $str);


texts: Customer Group Code Limited to 32 Chars - Why?

texts:
The name/code for customer groups is limited to 32 characters. A client has groups with names that are longer.

Is there any reason not to increase the length?


texts: Remove var Translator = new Translate from  section

texts:
When I install my language files (nl_NL) in my Magento 1.9.2.2 install, in the head section appears a JS tag that starts with:

var Translator = new Translate({...

What follows is a whole lot of strings in English and Dutch. In my opinion, this is bad for SEO.

My questions are:

is it really not good for SEO to have a whole lot of English and Dutch strings in the head?
how can I get rid of these strings (e.g. by creating a new, custom csv-file with translations)?

Hope there is anybody out there that can get me on track.


texts: Contact form file attachment not working

texts:
I have a file attachment in my contact form as you can see here:
http://www.cuylas.com/empleo/

I'm getting all of the fields but the file. Do you know where is the problem?

Thanks.

EDIT: Here's the code of my form page https://pastebin.com/2bupCGTx


texts: Magento2 Overriding template with plugin for Magento\Sales\Block\Order\Invoice\Items gives error with renderer list not found

texts:
I am receiving error when I use plugin to modify Invoice Items template.

Exception #0 (RuntimeException): Renderer list for block "sales.order.invoice" is not defined

This seems like a weird bug, I tried to add sequence in module.xml for Magento_Sales, but still gives the error.

Is there a better way to override this template file?

In my \Vendor\Module\etc\frontend\di.xml

<type name="Magento\Sales\Block\Order\Invoice\Items">
    <plugin name="vendor_module_sales_order_invoice_items" type="Vendor\Module\Plugin\Sales\Order\Invoice\Items" />
</type>

My plugin file \Vendor\Module\Plugin\Sales\Order\Invoice\Items.php

<?php
namespace Vendor\Module\Plugin\Sales\Order\Invoice;

use Vendor\Module\Helper\Data as Helper;

class Items
{
    protected $_helper;

    public function __construct(
        Helper $_helper
    )
    {
        $this->_helper = $_helper;
    }

    public function beforeToHtml($subject)
    {
        if(!$this->_helper->isEnabled()) {
            return;
        }

        $subject->setTemplate("Vendor_Module::sales/order/invoice/items.phtml");
        return;
    }
}

Has anyone else encountered this? And is there a better way to workaround this problem?
I am using Magento version 2.3.1.


texts: How do I make a product that is configurable and downloadable?

texts:
I have a set of downloadable products that need to be put together in a configurable product.  It all seems to work fine, except that the parent product isn't allowed to have a downloadable item assigned to it.

Is there a way to add a download file to a configurable parent product?

Or alternatively, is there a way to only allow users to purchase the child products, and not the parent product?

Or am I missing something here?


texts: Magento account controller rewrite set custom phtml file

texts:
I need to overwrite Account Controller and set another phtml templates for it.

I overwrites Account Controller .It working as I hope.but problem is i can't set my custom phtml template to it.

here is my config xml routing part

<frontend>
        <routers>
            <customaccount>
                <use>standard</use>
                <args>
                    <module>Company_Customaccount</module>
                    <frontName>customaccount</frontName>
                </args>
              </customaccount>

             <customer>
                <args>
                    <modules>
                    <customaccount before="Mage_Customer">Company_Customaccount</customaccount>
                    </modules>
                </args>
            </customer>

        </routers>
        <layout>
            <updates>
                <customaccount>
                    <file>Customaccount.xml</file>
                </customaccount>
            </updates>
        </layout>
    </frontend>

My account controller

<?php
require_once 'Mage/Customer/controllers/AccountController.php';
class Company_Customaccount_AccountController extends Mage_Customer_AccountController
{

 public function indexAction(){

$this->loadLayout();
        $this->_initLayoutMessages('customer/session');
        $this->_initLayoutMessages('catalog/session');

        $this->getLayout()->getBlock('content')->append(
            $this->getLayout()->createBlock('caacount/caccount.phtml')
        );
        $this->getLayout()->getBlock('head')->setTitle($this->__('My Account'));
        $this->renderLayout();

    }

}

I can't find what is issue.
when i  put die() into account controller.it show.it means it overwritten.


texts:
currently I have hardcoded my API token in my controller, Need to make it configurable so that it can be configured when the code is deployed in production.

So how can I store it on Magento variable from Magento cloud environment?

I see the variables section in configure environment in https://us-3.magento.cloud

If I set my customer variable there, then how can I access it in my controller file.

And what's with so many variables types in Magento and which should i use.

  https://devdocs.magento.com/guides/v2.3/cloud/env/variables-intro.html


texts: Magento 2: links between entities: best practices

texts:
I have a question regarding link between entities.
Consider that a car is linked to a brand. The car entity will have a brand_Id attribute.

Coming from the "Symfony universe", using the Doctrine ORM, the linked entities will be automatically generated and loaded if used.

echo $myCar->getBrand()->getName();

My question is : is there a way to do the same with Magento 2? Until now, I had to inject the linked entity repository and use lazy loading.

public function __construct(
        ...
        BrandRepositoryInterface $brandRepository,
        ...
) {

    $this->brandRepository = $brandRepository;
    ...
}

public function getBrand() {
    if($this->brand == null) {
        $this->brand = $this->brandRepository->getById($this->getBrandId());
    }

    return $this->brand;
}

Is there an alternative like in the Doctrine ORM? Or something else, a good MG2 practice for example?


texts: Get child categories instead of top in layered navigation

texts: I have issue on my site regarding layered navigation.i put all my categories under other like default->inventory->all categories.Now on filter or search it show inventory where i want to show sub categories.See image for results.I want to show sub categories instead of top but don't know from where i can set.


texts: Magento 2 : I want to add categories from front-end using controller in Magento 2

texts:
Here is the code I am using but it is given error. Please help. Thanks in advance.
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$rootCat = $objectManager->create('Magento\Catalog\Model\Category');
$cat_info = $rootCat->load(2);
$catName = "Tool Inventory";
$category = $objectManager->get('\Magento\Catalog\Model\CategoryFactory')->create();
$store = $this->storeManager->getStore();
$storeId = $store->getStoreId();
$url=strtolower($catName);
$cleanurl = trim(preg_replace('/ +/', '', preg_replace('/[^A-Za-z0-9 ]/', '', urldecode(html_entity_decode(strip_tags($url))))));
$category->setName($catName);
$category->setIsActive(true);
$category->setUrlKey($cleanurl);
$category->setData('description', 'description');
$category->setParentId($rootCat->getId());
$category->setStoreId($storeId);
$category->setPath($rootCat->getPath());
$objectManager->get('\Magento\Catalog\Api\CategoryRepositoryInterface')->save($category);


texts: There is not much information out on the internet about extending transnational emails. I need to be able to conditionally send emails to different departments based on the category and/or SKU of the item - where is a good start?


texts:
I want to know if is there any way to save the status/state of the order after the refund. When i create a credit memo the status of my order changes, i want to remove this change and keep it as it is even after refund, or at least change status to my custom status exp refunded. Any help on this?

Thanks in advance


texts: How to reorder the address in sales order csv

texts: I Want to reorder address data in sales order CSV instead of address displaying in this order (street, City, Region, Postal code ), I want to show it in this order(Postal code, Region, City, Street).


texts: Magento 2.2: How to completely disable customer login and registration

texts:
I have seen plenty of solutions for Magento 1.9, but I have not been able to find any conclusive way of disabling user accounts for Magento 2.

I'm developing a custom theme whose parent is Magento/blank.

I have no problem removing the login,signup,wishlist etc. from the frontend using XML and I've managed to remove any mention of customer accounts from the orders page (though I don't remember which process I followed to do so).

However, when my site loads I get an error in the console: Password fields present on an insecure (http://) page. This is a security risk that allows user login credentials to be stolen. Further, if the site is rendered as plain html then the login form is visible.

There will never be any customer accounts allowed on the store, so I'd like to remove all references to accounts on all pages.

I have followed 7ochem's answer to create a custom module for registration removal, modified for Magento 2 as follows:

app/code/[Vendor_name]/[Module_name]/registration.php

<?php
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    '[Vendor_name]_[Module_name]',
    __DIR__
);

app/code/[Vendor_name]/[Module_name]/etc/module.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="[Vendor_name]_[Module_name]" setup_version="1.0.0">
        <sequence>
            <module name="Magento_Customer"/>
        </sequence>
    </module>
</config>

app/code/[Vendor_name]/[Module_name]/Plugin/RegistrationPlugin.php

namespace [Vendor_name]\[Module_name]\Plugin;
use Magento\Customer\Model\Registration;
class RegistrationPlugin
{
    /**
     * @param Registration $subject
     */
    public function afterIsAllowed(Registration $subject)
    {
        return false;
    }
}

Using the  code inspector (firefox-aurora), I can see a script which contains the variable window.authenticationPopup = ..., so I presume that this module is not working properly.

EDIT:

Following JoshCarter's comments, I have added the following file:

app/code/[Vendor_name]/[Module_name]/etc/di.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Customer\Model\Registration">
        <plugin name="[Vendor_name]_[Module_name]::after" type="[Vendor_name]\[Module_name]\Plugin\RegistrationPlugin"/>
    </type>
</config>

After uploading this to the server, I executed the following commands:

$ php bin/magento indexer:reindex
$ php bin/magento setup:upgrade
$ php bin/magento setup:di:compile

During compilation, I receive the following error:

  [InvalidArgumentException] Plugin class [Vendor_name][Module_name]\Plugin\RegistrationPlugin doesn't exist.


texts: What is the recommended way to integrate to other services from Magento 2?

texts:
As part of building out an E-Commerence website for Company X, integrations into other systems within the company are required.  These integrations include Ordering and Payment services.  The APIs for these services are exposed via Rest and SOAP web services.

There are different approaches suggested by developers/engineers as to how we should write these integrations (as listed below).  What is the 'industry standard' when integrating into other services from magento 2?

The following suggestions were provided by different developers/engineers working on this E-Commerence website:

Create a separate PHP client library for Ordering and Payment services, and import these libraries within Magento.  As the customers place orders and make payments in Magento, use these client libraries to communicate with relevant services.  The business logic will reside within Magento.
Create a standalone service independent of Magento, which implements the Ordering and Payment services API and exposes its own combined Rest API.  As the customers place orders and make payments in Magento, take the in coming request objects, convert them to json, and forward json payload to this standalone service.  This standalone service will extract the data from json payload and make calls to Ordering and Payment services.  It will also have business logic and make API calls back into Magento for anything that needs to be updated.

Reasons for providing #2 solution are listed below and reasons against or reasons that nullify #2 are added as bullet points:

Portability - Install NodeJS or Java and run standalone servers anywhere

Magento 2 uses PHP 7 and is independent of operating system.  The PHP client libraries will also be portable.

Enterprise Solution - any group within the company can makes calls to the standalone service and use it for their purpose

Considering the standalone services make API calls back to Magento API, other groups within the company cannot use the standalone service since it will effect this E-Commerence website.

Scalability

It does not make sense to scale the standalone services without scaling Magento since Magento will be forwarding calling to these services (source of the load).  In order to handle increased load, both Magento and standalone services will need to be scaled together.

Separation of Concern

Using PHP client library, we can keep communication with Ordering and Payment services in the 'services' layer.
The business logic should remain within Magento.

Backward Compatibility - Upgrading to newer version of Magento will not affect communication with Ordering and Payment service.

Creating PHP client libraries for Ordering and Payment services will be independent from Magento and relies on PHP 7, not Magento.
If newer version of Magento changes the object structure for ordering or payments, the standalone services will not be able to parse new structure without an update.

Testing - Standalone services can be tested without Magento

True, but is it necessary to have the standalone services at all?


texts: Why does the billing information(country) change my prices?

texts: My store is located in Germany and when my customer set the country in billing information for example to the USA the prices of all my products will go down a bit. What can be the reason for this and how can I fix this?


texts: How to modify the keyword search in magento

texts: I have a list of 600 products in my store. When I use the quick search feautre of magento , it will display products that have the keywords. For example if I search for 'ck' it will display results that has names like 'ck calvin klien' and 'black'. I need to display products that has only words beginning with 'ck' and not words that ends with ck. The search at the moment is it for the name attribute.


texts: Magento 2.3.1- Problem with Payment not showing the payment options

texts:
I am having issues with magneto. checkout page will only show place order without giving the option to proceed to entering credit card details. I did a test order and clicked the place order button. I received order confirmation emails and the order are visible at the back end.

how can i solve this issue?

I have already performed this commands:

rm -rf var/cache/* var/page_cache/* var/generation/* var/di pub/static/* var/view_preprocessed/*
php -dmemory_limit=6G bin/magento deploy:mode:set production -s
 php -dmemory_limit=6G bin/magento setup:upgrade
 php -dmemory_limit=6G bin/magento setup:di:compile
 php -dmemory_limit=6G bin/magento setup:static-content:deploy
 php -dmemory_limit=6G bin/magento cache:flush


texts: How i can call SQL statement directly with magento 2

texts: how to call SQL statements directly to database with Magento 2, This is not recommended, but in some situation we need to do this, for some very special tasks


texts: Why you change the site's allowed countries old saved addresses still work

texts:
Initially in Countries Options country X was allowed.

Customer Y saved an address with country X.

Now I removed country X from Allow Countries. On checkout the country dropdown no longer shows country X.

But customer Y can still select to ship to his saved address which is in country X.

How can I fix it (don not allow to use saved addresses in country X)?

Thanks!


texts: Magento 2 add custom link to username dropdown

texts: can anyone tell me how to create a custom link ("MY VEHICLE") in the dropdown from username of a logged in user. I am a beginner and have no idea where to start, any help is greatly appretiated


texts: Is there a product attribute that tracks when the last time a product was updated?

texts:
I have a script that we run that calculates a bunch of custom product attributes between several currencies.  The one flaw with this script is that it runs through literally ALL products in our database. At the moment we have ~5K products, but in the next few months we will be importing several databases's of other products that will bring us up to ~150K products. Obviously this script will suddenly take hours to complete.  I'm trying to figure out a way to only run the products that have been recently updated (within the past day or a set period of time). The only thing I'm not sure of (and can't pin down) is if there is a product attribute that records when the product was last "re-saved".

If anybody knows what this field is called (or if it exists), it would be appreciated.


texts: Add clear button in frontend calendar button panel

texts:
I am trying to add a clear button in the jquery datetimepicker widget using the below code.

    define([
    'jquery',
    'ko',
    'Magento_Ui/js/form/element/abstract'
], function ($, ko, Component) {
    'use strict';

    return Component.extend({
        initialize: function () {
            this._super();
               var holidaysarray = window.checkoutConfig.shipping.delivery_date.holidaysarray;
            ko.bindingHandlers.datetimepicker = {
                init: function (element, valueAccessor, allBindingsAccessor) {
                    var $el = $(element);
                    //initialize datetimepicker
                    var options = {
                             beforeShowDay: function(date) {
                                var formateddatestring = jQuery.datepicker.formatDate('yy-mm-dd', date);
                                return [ holidaysarray.indexOf(formateddatestring) == -1 ];
                            },
                            beforeShow: function (input) {
                                this.dpClearButton(input);

                            },
                        };

                    $el.datetimepicker(options);

                    var writable = valueAccessor();
                    if (!ko.isObservable(writable)) {
                        var propWriters = allBindingsAccessor()._ko_property_writers;
                        if (propWriters && propWriters.datetimepicker) {
                            writable = propWriters.datetimepicker;
                        } else {
                            return;
                        }
                    }
                    writable($(element).datetimepicker("getDate"));
                },
                update: function (element, valueAccessor) {
                    var widget = $(element).data("DateTimePicker");
                    //when the view model is updated, update the widget
                    if (widget) {
                        var date = ko.utils.unwrapObservable(valueAccessor());
                        widget.date(date);
                    }
                },
                dpClearButton:function(input){
                    setTimeout(function () {
                    var buttonPane = $(input)
                    .datepicker("widget")
                    .find(".ui-datepicker-buttonpane");

                    $("<button>", {
                        text: "Clear",
                        click: function () { jQuery.datepicker._clearDate(input); }
                    }).appendTo(buttonPane).addClass("ui-datepicker-clear ui-state-default ui-priority-primary ui-corner-all");
                }, 1);
                }
            };

            return this;
        }
    });
});

I have added dpClearButton function but when run it give me error in console like Uncaught TypeError: this.dpClearButton is not a function


texts: I want to get all the shipping and billing info on magento product page, it should not go to cart page or anywhere order process should be completed on the product page.


texts:
I have installed two payment gateways on magento 2. Ccavenue payment gateway for India and PayPal for other countries. When we enter the PIN code of India, the payment gateway (Ccavenue payment gateway) is displayed. But when you enter the PIN code of any country outside, then Paypal is not visible. But after refreshing the page, Paypal appears

Before Refresh
After Refresh

error Showing in console
Uncaught TypeError: items is not a function at collection.js:276 at Function..each..forEach (underscore.js:150) at UiClass._updateCollection (collection.js:275) at UiClass.removeChild (collection.js:129) at UiClass. (element.js:547) at Array.forEach () at UiClass._clearRefs (element.js:546) at UiClass.destroy (element.js:514) at UiClass._super (wrapper.js:106) at UiClass.destroy (collection.js:235) at UiClass.destroy (wrapper.js:109) at iterator (observable_array.js:24) at underscore.js:73 at Function..each..forEach (underscore.js:145) at Function.each (observable_array.js:50) at UiClass.destroy (collection.js:237)


texts: Problem with save Qty for Item's Status to Become Out of Stock

texts:
I'm running a Magento Shop version 1.7 and have a problem with saving qty for an item's status to become "Out of Stock" from 0 to 2.

When I click on the button "save config", the browser is loading and loading a few minutes and when its finish I receive the message that the new config is saved - but when I check it again, the qty for Item's Status to Become Out of Stock number is not changed to 2 :(

Whats wrong? It is a bug?


texts:
After adding a simple product, went to view it in the front end, getting this error:

  Fatal error: Call to undefined method Mage_Catalog_Model_Product_Type_Simple::getUsedProducts() in /home/ottocap/public_html/app/code/core/Mage/Catalog/Model/Resource/Product/Type/Configurable/Attribute/Collection.php on line 160

Please help.


texts: Magento2 : Allow customer login only one device at a time

texts:
I want to allow customer to login in device one at a time.It should be similar to admin login functionality. If customer login to another device then from other device it should be logout.

Let me know solution for such functionality


texts: Magento 2 issues with programmatically creating child blocks

texts:
In trying to come up with my own solution to my other active question, I've been trying to add child blocks to my own custom block so that I can use them as renderers for the product options, thus replicating the general way that product forms are rendered on the product page.

The problem is that I get an error stating that the block I'm trying to add already exists. Taking that into account, I have tried several methods of determining if the child block already exists and none of them have worked yet.

Attempt 1 (check to see if we can get the child block)

protected function _prepareLayout() {
    if (!$this->getChildBlock('default')) {
        $childBlock = $this->getLayout()->createBlock('Magento\Catalog\Block\Product\View\Options\Type\DefaultType', 'product.info.options.default');
        $childBlock->setTemplate('Magento_Catalog::product/view/options/type/default.phtml');
        $this->addChild('default', $childBlock);
    }
    return parent::_prepareLayout();
}

Attempt 2 (check to see if the name already exists in layout)

protected function _prepareLayout() {
    $layout = $this->getLayout()
    if (!$layout->getChildName($this->getNameInLayout(), 'default')) {
        $childBlock = $this->getLayout()->createBlock('Magento\Catalog\Block\Product\View\Options\Type\DefaultType', 'product.info.options.default');
        $childBlock->setTemplate('Magento_Catalog::product/view/options/type/default.phtml');
        $this->addChild('default', $childBlock);
    }
    return parent::_prepareLayout();
}

Attempt 3 (check local variable to determine if this code has already been run)

protected function _prepareLayout() {
    if (!$this->_layoutPrepared) {
        $childBlock = $this->getLayout()->createBlock('Magento\Catalog\Block\Product\View\Options\Type\DefaultType', 'product.info.options.default');
        $childBlock->setTemplate('Magento_Catalog::product/view/options/type/default.phtml');
        $this->addChild('default', $childBlock);
        $this->_layoutPrepared = true;
    }
    return parent::_prepareLayout();
}

In each attempt, I have received the frontend error of "We're sorry, an error has occurred while generating this content." (which is spectacularly helpful considering error display is turned on).

From the exception log, I find this error twice: report.CRITICAL: Element with ID 'form_0.default' is already defined. which tells me that the code appears to be running multiple times.

What I gather from this is that somehow the code is being run three times: once successfully, and twice with errors. If I comment out the code, the child block cannot be found at all so it is not the case that there is a block with the same alias. It also doesn't matter what the alias is, as this has been tested with multiple variations.

I can't see any reason why _prepareLayout would get called multiple times, nor why it wouldn't be able to find the already existing child blocks and prevent the duplication using the code I have tried.

Any assistance in resolving this issue would be welcomed.

For reference, if relevant, this is Magento Commerce 2.2.2.


texts: How to make an overlay popup window on magento 1.9.2.3?

texts:
I was wondering if you could help me with the code that i should paste on promotion template in order to make a overlay popup window? I need to make a popup window come up when a customer puts a specific product to the cart (to let him know that if he buys an extra item, he will get a discount).
Thank you very much in advance,
Anna


texts: Checkout getting No such entity with orderId =

texts:
I'm using 2.3

But I don't know why when I place an Order I am getting No such entity with orderId=

How can I fix it?

look like this issue

update:

I check in chrome when i place an Order will showing

POST http://XXXX/rest/en/V1/carts/mine/payment-information 400 (Bad Request)

<response>
<message>
The consumer isn't authorized to access %resources.
</message>
<parameters>
<resources>self</resources>
</parameters>
<trace>
#0 public_html/vendor/magento/module-webapi/Controller/Rest/RequestValidator.php(68): Magento\Webapi\Controller\Rest\RequestValidator->checkPermissions() #1 public_html/vendor/magento/module-webapi/Controller/Rest/InputParamsResolver.php(80): Magento\Webapi\Controller\Rest\RequestValidator->validate() #2 public_html/vendor/magento/module-webapi/Controller/Rest/SynchronousRequestProcessor.php(85): Magento\Webapi\Controller\Rest\InputParamsResolver->resolve() #3 public_html/vendor/magento/module-webapi/Controller/Rest.php(188): Magento\Webapi\Controller\Rest\SynchronousRequestProcessor->process(Object(Magento\Framework\Webapi\Rest\Request\Proxy)) #4 public_html/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Webapi\Controller\Rest->dispatch(Object(Magento\Framework\App\Request\Http)) #5 public_html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Webapi\Controller\Rest\Interceptor->___callParent('dispatch', Array) #6 public_html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Webapi\Controller\Rest\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http)) #7 public_html/generated/code/Magento/Webapi/Controller/Rest/Interceptor.php(26): Magento\Webapi\Controller\Rest\Interceptor->___callPlugins('dispatch', Array, Array) #8 public_html/vendor/magento/framework/App/Http.php(135): Magento\Webapi\Controller\Rest\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http)) #9 public_html/generated/code/Magento/Framework/App/Http/Interceptor.php(24): Magento\Framework\App\Http->launch() #10 public_html/vendor/magento/framework/App/Bootstrap.php(258): Magento\Framework\App\Http\Interceptor->launch() #11 public_html/index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http\Interceptor)) #12 {main}
</trace>
</response>


texts:
I am looking for the alternative of _processDownload() function which is available in magento1.

I have tried to use the below snippet but it is not generating file.

$pdf = \Zend_Pdf::load($this->directory_list->getPath(DirectoryList::MEDIA) . DIRECTORY_SEPARATOR . $file);

$fileName = test.pdf;

$this->fileFactory->create(
        $fileName,
        str_replace('/Annot /Subtype /Link', '/Annot /Subtype /Link /Border[0 0 0]', $pdf->render()),
        \Magento\Framework\App\Filesystem\DirectoryList::VAR_DIR,
        'application/pdf'
        );


texts: Fresh installed magento 2.3 with sample data showing blank front page

texts:
Running mode: developer
I was getting blank frontend page. I checked system.log and debug.log in magento and found out there was some errors related to some broken reference.

main.INFO: Broken reference: the 'logger' element cannot be added as child to 'after.body.start', because the latter doesn't exist [] []
main.INFO: Broken reference: the 'theme.active.editor' element cannot be added as child to 'after.body.start', because the latter doesn't exist [] []

The frontend page was showing blank but it was actually loading some html.
I check for solution and found an answer in this thread
https://stackoverflow.com/questions/55928892/magento-2-blank-page-but-not-empty

This thread suggested to delete the global.php file located in generated/metadata, and following this solved my issue and front end of my website loaded properly.

But now whenever I run the command

php bin/magento setup:di:compile

the global.php file is generated again and my website's frontend shows blank page again and deleting global.php solves it.
I got some information related to global.php file in this thread Purpose of magento\generated\metadata\global.php file and is it safe to delete this file?

According to above thread

"The code compiler creates generated/metadata/global.php, which is a PHP serialized map of all constructor definitions mixed with object linking configuration defined in di.xml. di.xml is the dependency injection configuration. There is a global app/etc/di.xml and there can one defined for every module ."

This also happens when I run my website in production mode, and deleting global.php solves it.
Now my question is why magento is generating global.php file if it is neither using it in developer mode nor production mode as deleting this file does not give any error and the website works perfectly.

And also broken reference error in fresh install of magento, does it means that it is some bug related to magento and how can one debug this problem further.
I am asking how to debug it because as we can see in the error there is no mention of any file just a reference 'after.body.start'.

Update:
I am running it locally on my PC, and I am using xampp version-3.2.3 on windows operating system.


texts: How to optimize magento 2 performance at the first time?

texts:
After deploying production mode, merge js and css, minify HTML, Compile codes, enable Opcodes, Gzip, enable all caches (except "Varnish caches"),

I still see magento2 consume about 6-15s for the first time. From the 2nd time, it works smoothly.

The question is How I can improve performance for the first time request ?
I used XAMPP, PHP7 on window 8.


texts: Display Auto-generated Coupon code on success page

texts:
I am using Magento Enterprise 1.14.0.1
On the success.phtml I have a php code that automatically generates a coupon code. The code does generate the coupon I see in the Magento admin.However I can not figure out how to display it on the page?

Here is my code that generates the coupon

//Below is code to generate a coupon code and display it in a jquery popup window
$todaysdateis = date('Y-m-d', strtotime('+1 year'));
$generator = Mage::getModel('salesrule/coupon_massgenerator');

$data = array
(
    'max_probability'   => .25,
    'max_attempts'      => 10,
    'uses_per_customer' => 1,
    'uses_per_coupon'   => 1,
    'qty'               => 1, //number of coupons to generate
    'length'            => 14, //length of coupon string
    'to_date'           => "$todaysdateis", //ending date of generated promo
    /**
     * Possible values include:
     * Mage_SalesRule_Helper_Coupon::COUPON_FORMAT_ALPHANUMERIC
     * Mage_SalesRule_Helper_Coupon::COUPON_FORMAT_ALPHABETICAL
     * Mage_SalesRule_Helper_Coupon::COUPON_FORMAT_NUMERIC
     */
    'format'          => Mage_SalesRule_Helper_Coupon::COUPON_FORMAT_ALPHANUMERIC,
    'rule_id'         => 68 //the id of the shopping cart rule you will use as a template
 );

 $generator->validateData($data);
 $generator->setData($data);
 $generator->generatePool();

 //get the generate coupon code
 $salesRule = Mage::getModel('salesrule/rule')->load($data['rule_id']);
 $collection = Mage::getResourceModel('salesrule/coupon_collection')
              ->addRuleToFilter($salesRule)
              ->addGeneratedCouponsFilter();

 $thecode = $generator->getCode();

 echo "Your Code Is $thecode";

//End code to generate a coupon code and display it in a jquery popup window
?>

The goal is I want to eventually display this to the page not send it in an email.


texts: The requested URL /customer/account/login/ was not found on this server

texts:
How to solve this issue, If I manually add index.php it is working.

mydomain.com/index.php/customer/account/login/  -- works

mydomain.com/customer/account/login/ -- not working

my base url in core_config_data is  http://www.mydomain.com/


texts: Grouped product or configurable product?

texts:
I know it's frequently asking question. But I have a different problem related this.

In my store customer will pay different price by color and size.

For example:

X product: Blue, S: $500
M product: Blue, L: $1500
Y product: Yellow, S: $550
Z product: Green, L: $800
T product: Green, XXL: $1800

Which product type I need to use? Grouped or configurable?


texts:
I want to know what is meaning of this?

Magento no longer locks the category_product_entity table. Unlocking this table reduces the potential of lock-related timeouts that can occur when indexing and checkout operations run in parallel. Previously, Magento locked the category_product_entity table.

is it related to category product reindex? what related to this?


texts: Help with Model "sales/order" Status vs State

texts:
I have a csv file from our SAP system that has a list of order IDs and items within the order and quantity shipped for each item. I am trying to cycle through each order ID and load them in Magento and perform operations on them depending on their status or state (I'm not sure which one to use, please help!).

Basically, if an order is still processing/pending, I want to go into the items ordered and set the quantity shipped (and other things). However, I'm having difficulty understanding if I should use order state or status to get this information. Could someone help me understand which one to use and why?

I'm having a very hard time locating the Mage_Sales_Model_Order::getStatus() method. I've even used ReflectionClass to view the methods and do not see it! If I should use order status, I'd like to compare it with the Magento defined status (whether constant or db value), and not some literal string (i.e. "processing").

I'm using Magento Enterprise 1.13, but only 1.12 tag is available.


texts: Magento 2 : How to display Shipping Rates on a Product Page

texts:
I want to display Current product shipping rate on the product detail page.

I have tried below code,

$qty = 1;
        $countryId='IN';
        $storeId = 1;
        $zipcode = 360002;
        $product = $this->_catalogProduct->load($id);
        $item = $objectManager->create('Magento\Quote\Model\Quote\Item')->setProduct($product)->setQty(1);
        $store = $objectManager->create('Magento\Store\Model\Store')->load($storeId);
        $request = $objectManager->create('Magento\Quote\Model\Quote\Address\RateRequest')->setAllItems(array($item))
            ->setDestCountryId($country)
            ->setPackageValue($product->getFinalPrice())
            ->setOrigPostcode($zipcode)
            ->setPackageValueWithDiscount($product->getFinalPrice())
            ->setPackageWeight($product->getWeight())
            ->setPackageQty(1)
            ->setPackagePhysicalValue($product->getFinalPrice())
            ->setFreeMethodWeight(0)
            ->setStoreId($store->getId())
            ->setWebsiteId($store->getWebsiteId())
            ->setFreeShipping(0)
            ->setBaseCurrency($store->getBaseCurrency())
            ->setBaseSubtotalInclTax($product->getFinalPrice());
         $result = $this->_rateCollector->create()->collectRates($request)->getResult();

I want to display more than one enabled shipping methods rates in product display page. I have tried this code but i am getting this kind of error.

  Uncaught Error: Call to a member function getItemsQty() on null
  in/vendor/magento/module-quote/Model/Quote/Item.php:275

Please help me on this.


texts: Magento 2: How to get array of store_ids related to product/category?

texts:
I loaded a product.

Now I need to find out which stores it's assigned to (a list of store IDs will do).

Also - I need the same for category.


texts: In ui_component products get a grid of all products for each page and filtering does not work

texts:
In my file for ui_component:

<dataSource name="products_listing_data_source">
    <argument name="dataProvider" xsi:type="configurableObject">
        <argument name="class" xsi:type="string">Vendor\Module\Model\DataProvider\ProductsProvider</argument>
        <argument name="name" xsi:type="string">products_listing_data_source</argument>
        <argument name="primaryFieldName" xsi:type="string">entity_id</argument>
        <argument name="requestFieldName" xsi:type="string">id</argument>
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="component" xsi:type="string">Magento_Ui/js/grid/provider</item>
                <item name="update_url" xsi:type="url" path="mui/index/render"/>
                <item name="storageConfig" xsi:type="array">
                    <item name="indexField" xsi:type="string">id</item>
                </item>
                <item name="params" xsi:type="array">
                    <item name="id" xsi:type="string">${ $.id }</item>
                </item>
            </item>
        </argument>
    </argument>
</dataSource>

In Vendor\Module\Model\DataProvider\ProductsProvider i get collection with all products, how i can pass value QTY per page?


texts: Magento 2 data migration custom handler?

texts:
We are working on data migration using Magento 2 data migration tool. We would like to know how to write a custom handler for customer Id (or) product id.

Could you please advise did any work on this.

Thanks


texts: How to integrate third party library in magento 2 extension?

texts:
I am developing test (Custom Magento Extension) module and I want to integrate third party library into my Magento 2 extension which will be using files under this library.
Can anyone suggest how to integrate it into extension ?
API I am trying to integrate does not follow zend naming convention.


texts: Making non-customisable bundles in Magento 2

texts:
I am trying to remove the options from bundles (in Magento 2), so that Bundle Items can be added straight to the Cart without users being able to customise these options.

I thought the easiest way to do this would be to remove the customise button from the product page and replace it with the Add to cart button which appears in the Customise options. This has worked as far as the visual aspects are concerned. I have added Magento_Bundle/layout/catalog_product_view_type_bundle.xml with the following code which does this:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <move element="product.info.addtocart.bundle" destination="product.info.main" after="product.info.price"/>
        <referenceBlock name="customize.button" remove="true" />
    </body>
</page>

So far, so good! However, this Add to cart button doesn't work! There seems to be some Javascript which must kick in, in the block below, which I need to add here (or in a different file) perhaps?

Any ideas??


texts: Random error while creating storefront theme

texts:
Hi everyone I'm new to magento, few days ago I installed magento and now I was developing a sample storefront theme. But before i configure and install it, I just started facing an unknown error both on user end and admin side.

 Fatal error: Uncaught Error: Class 'Magento\Framework\App\DeploymentConfig\Reader' not found
 in C:\xampp\htdocs\magento\vendor\magento\framework\App\ObjectManagerFactory.php:215 Stack
 trace: #0 C:\xampp\htdocs\magento\vendor\magento\framework\App\ObjectManagerFactory.php(116):
 Magento\Framework\App\ObjectManagerFactory-
 >createDeploymentConfig(Object(Magento\Framework\App\Filesystem\DirectoryList),
 Object(Magento\Framework\Config\File\ConfigFilePool), Array) #1
 C:\xampp\htdocs\magento\vendor\magento\framework\App\Bootstrap.php(211):
 Magento\Framework\App\ObjectManagerFactory->create(Array) #2
 C:\xampp\htdocs\magento\vendor\magento\framework\App\Bootstrap.php(126):
 Magento\Framework\App\Bootstrap-
 >__construct(Object(Magento\Framework\App\ObjectManagerFactory), 'C:\\xampp\\htdocs...', Array)
 #3 C:\xampp\htdocs\magento\index.php(36):
 Magento\Framework\App\Bootstrap::create('C:\\xampp\\htdocs...', Array) #4 {main} thrown in
 C:\xampp\htdocs\magento\vendor\magento\framework\App\ObjectManagerFactory.php on line 215

When I try to run any command in magento directory it shows the following error in command-line:

PS C:\xampp\htdocs\magento> php bin/magento cashe:flush
An abstract factory could not create an instance of magentoframeworkappdeploymentconfig(alias:
Magento\Framework\App\DeploymentConfig).

I try to reinstall magento by composer update but this also does not fix the issue.

Many thanks in advance.

EDIT: Later on I also deleted my new storefront theme directory but no joys.


texts: cannot edit stores configuration with config cache enabled, disable yes

texts:
I am thinking i need to re install magento. It was installed on a subdomian folder with a subdomain, then when we wanted to go live to the tld, had trouble, and ended up just copying the install files and folders to the domain /public_html

if a re install is recommended, is it ok to install in on a subdomain test, then edit base urls and go live with the top level domain?d

Thanks!
Jack


texts: Magento Random Order Status goes back to Processing after marked as Process Printed / Shipped

texts:
I have a very strange problem with my Magento 2.2.6.

I am using M2E Pro to import orders automatically from Amazon. All the orders will be listed in Orders with Pending Status.

Then I would run a mass action to create invoice with status Paid.

Then I would put status to Process Printed(Custom Status with Processing State).

Next the issue happens. After some time (some 4 hours, some after 1 day, mostly random time) the status automatically changed to Processing. This not logged in comment history, not in the logs of M2E pro, not in the logs of any cron jobs(I have checked the updated time matching with the logs).

Comment History

And in the DB both the state and status is processing. As it's not added to the comment history makes this unable to trace.

Anybody have any idea why this is happening and how to trace this. I have looked in to all the solutions from the issue with automatic status change.

Thanks in advance.


texts: Magento logo image (placeholder) is added automatically

texts:
I have added several product images in the backend. Also I selected base image, small image and thumbnail image for the product in the backend. But in the frontend the Magento logo (placeholder image) comes first and the rest of the images comes after.

I have attached a screen shot below, indicating the problem.


texts: Why clear pub/static/frontend after css changes in dev mode?

texts:
I am working with Magento2 and have a question. I am working in the development mode.

But when I do some CSS changes in my theme, why I have to manually clear the pub/static/frontend folder every time (when I am in the developer mode).
This is very very slow.

How can I work faster?


texts: how we can use only alphabet on the customer username in the magento 1.9

texts: How can i add validations for only alphabets in First name and Last name fields in Customer registration form?


texts: Magento 2: Configuration not working when installed extension Ebizmarts_MailChimp?

texts:
i installed this extension than after configuration page not working!

showing below error :

1 exception(s):
Exception #0 (Exception): Notice: Undefined index: id in /home/ploma/public_html/vendor/magento/module-config/Model/Config/Structure/Element/Iterator.php on line 63

Exception #0 (Exception): Notice: Undefined index: id in /home/ploma/public_html/vendor/magento/module-config/Model/Config/Structure/Element/Iterator.php on line 63


texts: How to add a default value to checkout shipping postcode in magento 2

texts:
I am getting a zip code from the user when customer visit the website first time and saved the zip code using cookie.

I want to automatically set the zip code value saved in the cookie to checkout page shipping address postcode field.

How can i achieve this task.Please help me.strong text


texts: I don't see No Update on Category design backend

texts:
In Magento 2.3.4-p2 with Luma, when I try to save category in the backend I get this error message, "Something went wrong when saving the category", and I can't find out what is going on, but I realized that select in design -> Custom Layout Update is empty, I believe it should contain "NO Update". Does anyone have any ideas?
This is content from var / log / exception.log
[2020-06-17 10:08:53] main.CRITICAL: SQLSTATE [23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (photocolor_photocolor_m2.catalog_category_entity_varchar, CONSTRAINT CAT_CTGR_ENTT_VCHR_ENTT_ID_CAT_CTGR_ENTT_ENTT_ID FOREIGN KEY (entity_id) REFERENCES catalog_category_entity2 (...), query was: INSERT INTO catalog_category_entity_varchar ( attribute_id, _ ?, ?,?) ON DUPLICATE KEY UPDATEvalue = VALUES ( value) {"exception": "[object] (Zend_Db_Statement_Exception (code: 23000): SQLSTATE [23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (photocolor_photocolor_m2.catalog_category_entity_varchar, CONSTRAINT CAT_CTGR_ENTT_VCHR_ENTT_ID_CAT_CTGR_ENTT_ENTT_ID FOREIGN KEY (entity_id`` REF_ENCENTcatalog_category ... catalog_category ,store_id, entit y_id, value) VALUES (?,?,?,?) ON DUPLICATE KEY UPDATE value = VALUES (value) at / home / photocolor / public_html / vendor / magento / framework / DB / Statement / Pdo /Mysql.php:110, PDOException (code: 23000): SQLSTATE [23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (photocolor_photocolor_m2.catalog_category_entity_varchar, CONSTRAINT CAT_CT_TGR_T_GR_T FOREIGN KEY (entity_id) REFERENCES catalog_category_entity2 (...) at /home/photocolor/public_html/vendor/magento/framework/DB/Statement/Pdo/Mysql.php:91) "} []


texts: Magento: Category WYSIWYG Editor Image not displaying on custom page

texts:
I am getting category description on 2columns-left.phtml by following code:

Text are showing but media wysiwyg images not showing on frontend.

I am getting images in WYSIWYG Editor like:

How to display images on frontend of category description?


texts: Event for Post Dispatch on Newsletter not working in custom module

texts:
I have created an event on my new custom module to display something after new newsletter subscriber have subscribe both nothing is showing. I reference  this for event Here for  both postdispatch and predispatch

The event.xml shown below

<?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="controller_action_postdispatch_newsletter_manage_save">
    <observer name="controller_action_dispatch_newsletter" instance="Company\Module\Observer\Update" />
  </event>
</config>

This is the observer is shown below /observer/Update.php

 <?php
 namespace Company\Module\Observer;

 use Magento\Framework\Event\Observer;
 use Magento\Framework\Event\ObserverInterface;

class Update implements \Magento\Framework\Event\ObserverInterface
{

public function execute(\Magento\Framework\Event\Observer $observer)
{
    echo "email";
    exit; //un commet this to make sure event works
}
 }

Thank You


texts: Magento - Can clients order as guest even when they have an account

texts:
We use magento 1.8.1CE.

Customers have the option to check out as guest or make an account.

But is it also possible for customers who have an account to check out without logging in?
And if yes, how can i set this up?


texts: how to change image when we select dropdown value?

texts:
I have created a custom dropdown attribute name "manufactures_guarantee_length",
and its value like 1_year_guaranty,2_year_guaranty,3_year_guaranty, more,
in the product details page, I call that attribute,
now when we change the attribute value in any product that kind of image should change at the front-end product detail page,
for that, I have created a layout file catalog_product_view.xml and guaranty.phtml file,
in phtml file, I code like
<?php $product = $block->getProduct(); ?>
<?php echo $product->getData('manufactures_guarantee_length'); ?>

so I get the value of dropdown, so now how to change like Image as per dropdown?
please suggest me on this.
Thanks in advance.
.


texts:
I am not able to implement a custom theme in Magento 2 (on mac os x)
can you provide me with information please?


texts: delete session files older than one day, not working

texts:
I would like to clean session files older than one day.

I clean with cron with this

find /path/to/magento/var/session/ -mtime +1 -exec rm {} \;

and my cron setting is to run once a day, so

0 0 * * *

But it seems to be not working correct.
As of now (9:07 am 16 July 2017), oldest session file's last modified time/date is 20:03 14 July.

What am I doing wrong??


texts: Magento community site with 2 storefronts- need to know how to define User roles in different locales.

texts:
Hi I have a magento community site with 2 storefronts targeting different locales. The site is mainly administered from the UK but our office in Australia will need to make edits to it too. My problem lies in the CMS in that i need to make sure that the AU staff cant make any changes to anything that will affect the UK catalogue. All the products are in a shared catalogue with the ability to bespoke attributes (like price, meta) for different storefronts.
Basically I need to be able to make sure that the user roles in the website can be set up to only allow for any changes to be made in their storefront.
I was wondering if this isn't possible if there is such thing as a 'change history' defined by user?

Thanks in advance for any help :-)


texts: Do string manipulations on catalogsearch result url's query

texts:
I am trying to include "Category" search in the Advanced search of my project. By going through some Stackoverflow questions, I realized that magento has built-in code for category search but they haven't used it.

I mean while searching if I add a param as cat then that will represent Category. So, for example:

www.mywebsite.com/catalogsearch/result/?cat=37&q=shoe

In the above url, the cat param represents the id of Category. Hence, the search of string shoe will be specific to the provided category id.

(ignore me if this is a known thing and a unnecessary explanation)

Now, what I am trying to do is split the search text in to two halves based on a colon(:). such that the first part will be the "Category Name" and the second half will be the "Product Name" then I will append the catalogsearch/result url this new params.

For example, if the search string provided by user is Mobile:Blackberry, then I will extract the category Id from the provided category name and pass the query as follows:

?cat=37&q=Blackberry

I am not sure where exactly I should do this string manipulations.

Please guide me.


texts: Magento getCollection function returning db info not data

texts:
i want to get all orders from Magento but its returning the db info not the data

class Host_Autox_OrderController extends Mage_Core_Controller_Front_Action
{
    public function indexAction(){
        $ordersCollection = Mage::getModel('sales/order')->getCollection();
        echo "<pre>"; print_r($ordersCollection->getData());
    }

}

And here is the output

object(Mage_Sales_Model_Resource_Order_Collection)#70 (34) { ["_eventPrefix":protected]=> string(22) "sales_order_collection" ["_eventObject":protected]=> string(16) "order_collection" ["_model":protected]=> string(11) "sales/order" ["_resourceModel":protected]=> string(11) "sales/order" ["_resource":protected]=> object(Mage_Sales_Model_Resource_Order)#102 (21) { ["_eventPrefix":protected]=> string(20) "sales_order_resource" ["_eventObject":protected]=> string(8) "resource" ["_grid":protected]=> bool(true) ["_useIncrementId":protected]=> bool(true) ["_entityCodeForIncrementId":protected]=> string(5) "order" ["_useIsObjectNew":protected]=> bool(true) ["_entityTypeForIncrementId":protected]=> string(0) "" ["_virtualGridColumns":protected]=> NULL ["_gridColumns":protected]=> NULL ["_resources":protected]=> object(Mage_Core_Model_Resource)#83 (5) { ["_connectionTypes":protected]=> array(0) { } ["_connections":protected]=> array(69) { ["core_setup"]=> object(Magento_Db_Adapter_Pdo_Mysql)#38 (31) { ["_defaultStmtClass":protected]=> string(29) "Varien_Db_Statement_Pdo_Mysql"

Something like that

Update

is there any limit to getData because its only fetching approx 1200 records after that it shows the blank page. Getting this error.

Fatal error: Unknown: Cannot use output buffering in output buffering display handlers in Unknown on line 0


texts: Display all one page checkout steps at once (for development)

texts:
I want to style the onepage checkout and would like to make all steps visible temporarily for development, so I don't have to keep going through each step to style it.

Is there any way I can achieve this?


texts: Magento2 images for indevedual Store like example.com base, small, thumbnail image not get selected in programmatically adding images to the products

texts:
I am adding images to the products from a folder programmatically using addImageToMediaGallery function. below is my controller code
<?php
namespace Kammalou\AddMissingImages\Controller\Missing;
use Magento\Framework\View\Result\PageFactory;
use Magento\Framework\App\Action\Context;

class Images extends \Magento\Framework\App\Action\Action
{
    protected $pageFactory;
    public function __construct(Context $context, PageFactory $pageFactory)
    {
        $this->pageFactory = $pageFactory;
        return parent::__construct($context);
    }

    public function execute()
    {
        var_dump(__METHOD__);
        $page_object = $this->pageFactory->create();
        $obj = \Magento\Framework\App\ObjectManager::getInstance();
        $productCollection = $obj->create('Magento\Catalog\Model\ResourceModel\Product\CollectionFactory');
        $collection = $productCollection->create()->addAttributeToSelect('*')->load();

        foreach ($collection as $product){
            $productId =  $product->getId() ; // Id of product
            $product = $obj->create('Magento\Catalog\Model\Product')->load($productId);
            $image = $product->getImage();
            if($image =='' || $image=='no_selection' ){
               // echo 'Name  =  '.$product->getName().'
';

                $imagePath = "/var/www/vhosts/m2atimedev/httpdocs/var/inriver/pics/".$product->getName().".jpg";
                // path of the image
                //echo $imagePath;exit;
                if(file_exists($imagePath)){
                    //Remove Images From Product

                    $productRepository = $obj->create('Magento\Catalog\Api\ProductRepositoryInterface');
                    $existingMediaGalleryEntries = $product->getMediaGalleryEntries();
                    if($existingMediaGalleryEntries){
                        foreach ($existingMediaGalleryEntries as $key => $entry) {
                            unset($existingMediaGalleryEntries[$key]);
                        }
                    }
                    $product->setMediaGalleryEntries($existingMediaGalleryEntries);
                    $productRepository->save($product);

                    // Adding Image to product
                    $product = $obj->create('Magento\Catalog\Model\Product')->load($productId);
                    $product->addImageToMediaGallery($imagePath, array('image', 'small_image', 'thumbnail'), false, false);
                    $product->save();
                }
                //echo 'image  =  '.$product->getImage().'
';

            }
        }

        return $page_object;
    }
}

The code is working very fine. but the problem is when images are set as thumbnail only for default magento scope. In the store scope image is showing but not selected as thumbnails.

when i change scope, the base small thumbnail image does not show selected.

As a result in the frontend the images are not showing with the products on category and search results page.

If we click on products with missing images, than on the product page images is showing correctly.
How to show images with products on category page programmatically. Right now i have to go to backend, select product, change scope to store and set base, small and thumbnail image.


texts: Magento 2.3: who knows how to place the cart summary into the static block on any page?

texts: I am trying to place the cart summary to the static page with products. I wanna locate it to the right from the grid of products (listed using Catalog Products widget). Anybody knows how to do this? Will appreciate if anybody can help.


texts: How I can add Gallery Images for custom form in Magento 2

texts:
I am creating a Custom form in admin of magento 2,and I want to add media gallery for same product form(Images and video Tab https://prnt.sc/w926fk ) into this form https://prnt.sc/w928bi
please help me with this issue . Thank much!


texts: Magento 1 tax calculation and product price showing ambiguity

texts:
I am having a strange issue regarding tax calculation. I am using tax prices included in catalog price while adding prices and enabled this in tax calculation too. Also I want to show Ex-Tax price on my site frontend in catalog page. I enabled this too on catalog page display settings.

So the issue is its works fine for some time but then it started to causing issues. It start to include the Tax again and add this in total so price started showing wrong. When this issue occurred we generally changed any tax settings

  (like tax calculation based on field to shipping origin and it work
  fine for few days and when issue happened again we changed back it to
  shipping address)

and then it started calculating correctly.

I am so confused why this is happening and then resolve just changing any setting not just the tax calculation based on field.

Please let me know any idea or probability for this issue.

Thank you


texts: How to display stock information on product page?

texts:
I would like to display the stock status (In Stock | Sold Out) on the product page.

How can I achieve that?


texts: Magento 1 : Unable to save the Static blocks on edit existing blocks

texts:
I have 1.9.0.3 Magento website, everything was fine, website wasnt edited in a year and when I tried to edit some existing static block and save or save and continue editing I am returned in CMS/Static Blocks panel and no changes are made.
It allows me to create new static block, but when I copy paste code from existing old block same happened.
What I noticed when playing with blocks when I copy/paste code from existing block in new block for example:

    <div class="item" style="background:url({{media url="wysiwyg/porto/homepage/slider/02/13_new.jpg"}})

Cant save the new created block. When I remove word "style" everything is ok and block is saved. It happen with all lines with "style". Code is not proper without "style" but block is saved.
I flushed everything, deleted cache, same happened.
In system.log I found error that repeats 20 times per day in last 12 months:

2019-05-20T16:27:25+00:00 ERR (3): Warning: Invalid argument supplied for foreach()  in /home/fedorsoaps/public_html/app/code/local/Smartwave/Socialfeeds/Helper/Data.php on line 79

And, line 79 in Data.php is:

 79    foreach ($doc->getElementsByTagName('ul')->item(0)->childNodes as $child) {
        $raw = $doc->saveXML($child);
        $li = preg_replace("/
]+\>/i", "", $raw);
        $peopleList[$i] = preg_replace("/<\/li>/i", "", $li);
        $i++;

Meanwhile website frontend is working normally but I cant make any changes.
I am not coder, just basic Magento installer, thanks for any help.


texts: How to use if else statement in email subject

texts:
I have been trying to check a condition on subject section of magento's transactional email.

I'm trying to display order status on subject except for pending.

This is what i have tried so far.

{{if  order.status!="pending"}} {{var order.status}} {{else}} test {{/if}}

Unfortunately this is not working as expected. I'm always getting else condition.

I have no idea why this condition is not working

order.status!="pending"

Any kind of help would be appreciated.


texts: Magento2: How to get Cart items collection on Product view page?

texts:
I want to get Cart items collection on product page.

customer-data.js

define([
    'jquery',
    'ko',
    'uiComponent',
    'Magento_Customer/js/customer-data'
], function ($, ko, Component, customerData) {
    'use strict';

    return Component.extend({
        /** @inheritdoc */
        initialize: function () {
            this._super();
            this.items = customerData.get('cart')().items //get cart items
            console.log(this.items);
        }
    });
});

product.phtml

             Product ID

Help me.


texts: I want to add horizontal tabs in the Magento 2 admin

texts:
I want to show horizontal tabs in the Magento 2 admin and inside each tab, there will be a form created using ui_component.

Just like this, can anyone help me to achieve this?


texts:
In Magento I am calling a long time running function using Ajax. When I open any admin page in a new tab it shows "continue loading" until the Ajax request is completed in the previous tab.

I want to continue my work on other tabs while the Ajax process is running on one tab, how can I do it?


texts: Get Customer Details by Wishlist Product Id in Magento 2

texts:
A list of products was added to wish-list by the number of customers and I need to know that which customer was added a particular product to the wish-list, based on the product id.

I need to get the customer details or at-least a customer id based on the product id.


texts:
I'm importing images from another store that are already on a CDN. I've set the config>web Base Media URLs to the CDN for both Secure/Unsecure. When I look at the products in admin, I get a broken image. When I check the html, the "onmouseover" event has the correct url in parenthesis, but the img tag has a "catalog/product/" path imbedded in between the CDN and the  image path. When I mouseover, the console shows it trying to fetch the invalid path with the "catalog/product/" path.

mouseover: https://cdn.foo.com/products/images/1/1.jpg

img tag source: https://cdn.foo.com/catalog/product/products/images/1/1.jpg

Is there a setting somewhere I'm missing so I can just get my image or do I have to mess with the skin?


texts: Magento 2.1 : Grid duplicate checkbox id_ issue on add new and edit form

texts:
<input name="" value="3" id="id_3" class="checkbox admin__control-checkbox" checked="checked" type="checkbox">

I Want to check/unchecked the tags and holidays to attach them to my store as shown in the picture, but the ids of the checkboxes conflict with each other;as they appear duplicate from both tags and holidays- if you check id 3 of holiday it will also check the id 3 of tags, in both grids the ids appear in the format id="id_3".How can I change the format id_x to something like idz_x .

protected function _prepareColumns()
{

        $this->addColumn(
            'in_gmaps',
            [
                'header_css_class'  => 'a-center',
                'type'              => 'checkbox',
                'type' => 'checkbox',
                'name' => 'in_gmaps',
                'values' => $this->_getSelectedProducts(),
                'index' => 'holiday_id',

            ]
        );
    $this->addColumn(
        'holiday_id',
        [
            'header' => __('ID'),
            'sortable' => true,
            'index' => 'holiday_id',
            'header_css_class' => 'col-id',
            'column_css_class' => 'col-id'
        ]
    );
    $this->addColumn('holiday_name', [
        'header'    => __('Title'),
        'align'     =>'left',
        'index'     => 'title',
     ]);
     $this->addColumn('holiday_name', ['header' => __('Holiday Name'), 'index' => 'holiday_name']);
    $this->addColumn('holiday_description', ['header' => __('Holiday Description'), 'index' => 'holiday_description']);
    $this->addColumn(
        'position',
        [
            'header' => __('Position'),
            'type' => 'number',
            'index' => 'position',
            'editable' => 'false'
        ]
    );

    return parent::_prepareColumns();
}

And the entire row is

    <input name="" value="3" id="id_3"
    class="checkbox admin__control-   checkbox" type="checkbox">

    3


texts: issues while editing the custom attribute for a category in multi-language store

texts:
My store is multilanguage and I created an image type attribute for my category. What happens is that when I edit this image with the "all store views" option enabled, it changes correctly in all languages except one of them, which coincidentally (or not) is the default language of the store. I do not know if this is a default behavior or a Magento bug.

Does anyone have any idea how to solve this?


texts: What is the visitors' HTTP User Agent stored in log_visitor_info used for?

texts:
I was wondering, where in Magento the visitors' HTTP User Agent Information is used. The log_visitor_info table is pretty big (and for me it seems the user agent information is useless?).

I grepped through the code and all I found were the following three usages:

Check for ignored user agents (anyway, not the stored user agent data but the one received from the helper) (see Mage_Log_Model_Visitor, _construct())
Adding the user agent information in (Mage_Log_Model_Visitor, initServerData())
Saving the visitor information (Mage_Log_Model_Resource_Visitor, _saveVisitorInfo())

Is there any other place (Reports, Menu item in the backend,...) where the HTTP user agent information is shown/needed?


texts: can't see paypal payment option in magento admin panel

texts:
I made a change in /app/code/core/Mage/Paypal/Model/Config.php file

protected $_supportedCurrencyCodes = array('AUD', 'CAD', 'CZK', 'DKK', 'EUR', 'HKD', 'HUF', 'ILS', 'JPY', 'MXN', 'NOK', 'NZD', 'PLN', 'GBP', 'SGD', 'SEK', 'CHF', 'USD', 'TWD', 'THB');

Changed code,

protected $_supportedCurrencyCodes = array('AUD', 'CAD', 'CZK', 'DKK', 'EUR', 'HKD', 'HUF', 'ILS', 'JPY', 'MXN', 'NOK', 'NZD', 'PLN', 'GBP', 'SGD', 'SEK', 'CHF', 'USD', 'TWD', 'THB', 'INR');

since this change i can't see paypal payment option anywhere in my magento admin panel.

I even revert the changes, clean the cache, re-index file but still no luck.


texts: Magento 2: How can I align columns in sales order template

texts:
i wanted to align the column for items qty and price so that they can be space out and not grouping together as it is now.

I know which file to edit, but how to "crack open" the {{layout handle="sales_email_order_items" order=$order area="frontend"}}

Does anyone know how I can align this info into a proper table?


texts: Magento 2: create multiple contact form with different recipients

texts:
I need to create multiple contact forms, with different recipients.
The contact forms I want to create, has to have the same fields, nothing fancy.

I just need to create different simple contact forms, each of them, with a different recipient.

Or eventually, I just need ONE contact form with a dropdown, that basing on the selection, it will send to a particular recipient.

Please, help me!


texts: How do I add a css file to the head block in Magento 2

texts:
I'm building a Magento 2 module for learning purposes.
I'm trying to add a css file to all configurable product pages but I'm failing miserably.

Here is what I tried.
In app/code/Namespace/Module/view/frontend/layout I added this file: catalog_product_view_type_configurable.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../Magento/Core/etc/page.xsd">
    <referenceBlock name="head">
        <block class="Magento\Theme\Block\Html\Head\Css" name="namespace-module-css">
            <arguments>
                <argument name="file" xsi:type="string">Namespace_Module:css/styles.css</argument>
            </arguments>
        </block>
    </referenceBlock>
</page>

The layout file is taken into consideration but I get the following error in the console

  403 Forbidden - ROOT/pub/static/frontend/Magento/blank/en_US/Namespace_Module:css/styles.css

The file mentioned in the error message does not exist (it is not generated) even if the original file I'm trying to add exists in /app/code/Namespace/Module/view/frontend/web/css/styles.css
If I remove the Namespace_Module prefix from the <argument> tag it includes a different styles.css. The one from pub/static/frontend/Magento/blank/en_US/css/styles.css.

What am I doing wrong?


texts: Can we write a  in out layout file without any "type" parameter?

texts:
Can we write a block tag in our layout without its type parameter, such as below

<block  name="formInput" template="Pfay/UserForm/FormInput.phtml" />

what is the other way to do this if i don't have any block associated to my template file ?


texts: Magento 2 add order data to custom field

texts: I have added an extra field in the sales_order_item table. How can I add order data from a custom attribute of a product into this extra field when an order is placed? which file should I change? Code example is appreciated.


texts: Homepage was not listing given category products

texts:
I have added the design code as like this in homepage.

<reference name="content">
<block type="catalog/product_list" category_id="548"  template="catalog/product/list.phtml">
</block>
</reference>

but the particular category-id related products are not displaying... but displaying all the category products..

how to make it to display the particular category id related products.


texts:
Error filtering template: Notice: Undefined variable: pro_price in
/Magento_Catalog/templates/product/widget/new/content/categories_shop.phtml on line 112

i'm getting this error even if comments or remove pro_price variable.
code where i'm getting this error ,its comes after deleting most of the products from catalog. before this was working fine. any suggestion?
this small code from file

$type = 'widget-new-grid';
$categoryProducts = $category1->getProductCollection()->addAttributeToSelect('*');
foreach ($categoryProducts as $product) {
     $pro_price=$block->getProductPriceHtml($product, $type);
}


texts: How can I display an attribute below a product?

texts:
For example I am setting up a store that sells music in Magento and I want the title of the product to just be the album name, I then have attributes such as 'artist' and 'format' that I would like to display below the title.

So for example it would display the title of the album, then below it would display the artist and the format ie 'CD'.

How can I do this?


texts: Payment : Square Payment - Magento refund issue - Missing the required parameter $location_id

texts:
I am using square payment gateway. Magento admin refund issue, error message :

  Could not refund payment: Missing the required parameter $location_id
  when calling createRefund If the invoice was created offline, try
  creating an offline creditmemo.

How to solve the issue?


texts:
I am adding some links to my footer_links block, however I want them to be the last links added.

In my local.xml file I have:

<reference name="footer_links">
    <action method="addLink" translate="label title" ifconfig="mymodule_options/style/fb_link">
        <![CDATA[]]>
        <url helper="mymodule/getFbLink" />
        <title>Facebook</title>
        <prepare/>
        <urlParams/>
        <position>10</position>
        <liParams>
            <class>left</class>
        </liParams>
        <aParams>
            <target>_blank</target>
        </aParams>
    </action>

</reference>

I have set the position attribute as a variety of values, but it is still appearing at the top of the list of links.

Some Googling suggests that the parameters need to be in the same order as the function call addLink. The signature for this function is:

public function addLink($label, $url='', $title='', $prepare=false, $urlParams=array(), $position=null, $liParams=null, $aParams=null, $beforeText='', $afterText='')

As you can see, the position is in the correct place.

How do I set the position of my link to the bottom of the list via xml?


texts: Custom email from module works on localhost, empty on live server (m2)

texts:
Any ideas? I send an email from my custom module, and it works locally (AMPPS), but on live server it does not work. It just sends an empty email (no subject and no content).

Controller file

namespace Lala\EmailRegistrationData\Controller\Index;

class SendEmail extends \Magento\Framework\App\Action\Action
{
    public function execute()
    {
        // Sending email
        $templateOptions = array('area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $storeManager->getStore()->getId());
        $templateVars = array('store' => $storeManager->getStore(),);
        $from =  'general'; /* array('email' => "test@webkul.com", 'name' => 'Name of Sender'); */
        $inlineTranslation->suspend();
        $to = array('myemail@gmail.com');

        $transport = $transportBuilder->setTemplateIdentifier('email_registration_template')
                        ->setTemplateOptions($templateOptions)
                        ->setTemplateVars($templateVars)
                        ->setFrom($from)
                        ->addTo($to)
                        ->getTransport();
        $transport->sendMessage();
        $inlineTranslation->resume();
     }
}

email_templates.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Email:etc/email_templates.xsd">
    <template id="email_registration_template" label="Send email registration data" file="email-registration-data.html" type="html" module="Mediq_EmailRegistrationData" area="frontend"/>
</config>

Email template file:

New user registration form submitted

Again, it works great on my PC (via AMPPS), but as soon as its on live server, I only receive an empty email - no subject and no body.

Any ideas?


texts:
Is there any way to drop step 6 from the checkout and have the place order button straight on step 5. So it attempts payment immediately?

Thanks


texts:
This is my code

<?php /* @escapeNotVerified */
$json=$block->getGalleryImagesJson();
$array = json_decode($json,true);
foreach($array as $item)
{
    $imgurl = $item['full'];
    echo '';

}
?>

and I am getting error  on this line

echo '';

as

  Parse error: syntax error, unexpected 'url' (T_STRING), expecting ','
  or ';' in
  C:\wamp64\www\ekelund1692\app\design\frontend\Pronko\ekelund\Magento_Catalog\templates\product\view\gallery.phtml
  on line 8


texts:
I want to display subcategoies and their products on parent category page
I tried this code on ../Magento_Catalog/templates/category/products.phtml but it shows all product of the parent category on each subcategories

<?php $category = $block->getCurrentCategory(); ?>
<?php $subcategories = $category->getChildrenCategories(); ?>
<?php $_helper = $this->helper('Magento\Catalog\Helper\Output'); ?>
<?php $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); ?>
<?php if(count($subcategories) > 0): ?>

            <?php foreach($category->getChildrenCategories() as $subcategory): ?>
                <?php $subcategory = $objectManager->create('Magento\Catalog\Model\Category')->load($subcategory->getId()); ?>

                        <?php if ($_imgUrl = $subcategory->getImageUrl()): ?>
                            <a href="<?= $subcategory->getUrl() ?>" class="product photo product-item-photo">

                                    <?php $_imgHtml = ''; ?>
                                    <?php echo $_imgHtml = $_helper->categoryAttribute($subcategory, $_imgHtml, 'image'); ?>

                        <?php endif; ?>

                                <a class="product-item-link" href="<?= $subcategory->getUrl() ?>"><?= $subcategory->getName() ?>

                            <?= $block->getProductListHtml() ?>

            <?php endforeach; ?>

<?php else: ?>
    <?php if (!$block->isContentMode() || $block->isMixedMode()): ?>
        <?= $block->getProductListHtml() ?>
    <?php endif; ?>
<?php endif; ?>

help please


texts:
please help me edit the subtotal of a completed order, There was an order placed for COD and it was delivered with invoice photoshoped with new values however i want to change the subtotal in the system.
I knew it is possible through database edit. some one please guide me.


texts: How to change "input file" storage location in customer account edit form

texts:
I have added a customer attribute called "My File". It gets added in customer account edit form. By default, the selected file(My File) is saved under "pub/media/customer" directory. In my case, I want to save those files alone under "pub/media/my_files". How to achieve it? Please help me!

Creating attributes in InstallData.php

use Magento\Customer\Setup\CustomerSetupFactory;
use Magento\Customer\Model\Customer;
use Magento\Eav\Model\Entity\Attribute\Set as AttributeSet;
use Magento\Eav\Model\Entity\Attribute\SetFactory as AttributeSetFactory;
use Magento\Framework\Setup\InstallDataInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\App\ProductMetadataInterface;

/**
 * @codeCoverageIgnore
 */
class InstallData implements InstallDataInterface
{
    /**
     * Customer setup factory
     *
     * @var CustomerSetupFactory
     */
    private $customerSetupFactory;

    /**
     * Customer Attribute setup factory
     *
     * @var AttributeSetFactory
     */
    private $attributeSetFactory;

    /**
     * Customer Attribute setup factory
     *
     * @var ProductMetadataInterface
     */
    private $productMetadataInterface;

    /**
     * Init
     *
     * @param CustomerSetupFactory $customerSetupFactory
     * @param AttributeSetFactory $attributeSetFactory
     * @param ProductMetadataInterface $productMetadataInterface
     */
    public function __construct(CustomerSetupFactory $customerSetupFactory, AttributeSetFactory $attributeSetFactory, ProductMetadataInterface $productMetadataInterface)
    {
        $this->customerSetupFactory = $customerSetupFactory;
        $this->attributeSetFactory = $attributeSetFactory;
        $this->productMetadataInterface = $productMetadataInterface;
    }

    /**
     * {@inheritdoc}
     * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
     */
    public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
    {
        /** @var CustomerSetup $customerSetup */
        $customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);

        $customerEntity = $customerSetup->getEavConfig()->getEntityType('customer');
        $attributeSetId = $customerEntity->getDefaultAttributeSetId();

        /** @var $attributeSet AttributeSet */
        $attributeSet = $this->attributeSetFactory->create();
        $attributeGroupId = $attributeSet->getDefaultGroupId($attributeSetId);

            $attributeList['my_file'] = [
                'type' => 'varchar',
                'label' => 'My file',
                'input' => 'file',
                'required' => false,
                'visible' => true,
                'user_defined' => true,
                'sort_order' => 150,
                'position' => 150,
                'system' => 0,
                'validate_rules' => '{"max_file_size":1048576,"file_extensions":"pdf,jpg,png,jpeg,PDF,JPG,PNG,JPEG"}'
            ];

        $attributeList['my_file_link'] = [
            'type' => 'varchar',
            'label' => 'My File Link',
            'input' => 'text',
            'required' => false,
            'visible' => true,
            'user_defined' => true,
            'sort_order' => 160,
            'position' => 160,
            'system' => 0
        ];

        foreach ($attributeList as $key => $value) {
            $customerSetup->addAttribute(Customer::ENTITY, $key, $value);

            //add attribute to attribute set
            $attribute = $customerSetup->getEavConfig()->getAttribute(Customer::ENTITY, $key)
                            ->addData(
                                [
                                'attribute_set_id' => $attributeSetId,
                                'attribute_group_id' => $attributeGroupId,
                                'used_in_forms' => ['customer_account_edit', 'checkout_register', 'adminhtml_customer']
                                ]
                            );

            $attribute->save();
        }
    }
}


texts: Imported products from magento 1.7 site are not visible on magento 1.8 site

texts:
I imported all products from magento 1.7 site to  freshly installed 1.8 site. both are different sites. but products are same. after "run Profile" , i got message on screen "import successfull". Products are present in admin panel. but it's not visible on frontend.

Please give me your suggestions to make products visible on frontend.

Thanks.


texts:
Using Magento 2.3 and after some extensive digging, it seems that either fotorama or another that loads the images on product list and product page runs several instances of PHP-FPM all at high usage, if there are a few photos on the product it can sometimes hang and keep loading. I then have to restart the PHP-FPM service for the page to load properly with the images.

The server is a VPS, running 16GB RAM and 6 Core CPU.

What should i be looking for next to fix this?


texts: Send reviews to google plus and also get reviews from there to site

texts:
I want to know about Google plus review page.

How to post reviews on Google plus business page?
How to get those reviews from Google plus business page to Magento site and vice a versa?

Note: I am not talking about Google place API reviews.

As I analyze, you can display tweets on your site from twitter.

But is it also possible with Google Plus? How?


texts: How can I add colums to magento 1.9.2.3 Nav menu?

texts:
I currently have:

Shoes
[ ALL ]
[Men's ]
[Ladies]

It's pretty basic and standard. I also have brands [hidden from menu] - things like /shoes/nike.html etc.

I want to add a column to the top menu to hold links to brands. I have played with html/css using divs to hold the columns. How do I translate this over to magento or can you think of a better way to achieve this?!


texts: Magento 2: Observer or Plugin for Mass Update Product Attribute

texts: I have a custom attribute that I need to observe after the mass update product has been finished, this custom attribute is related to a category in another custom table, so if this custom attribute value changed I need to assign a new category id to the product. My question is what observer or plugin is suitable for this kind of action? i also need to get the previous attribute value and the new attribute value


texts: How to increase the quality of product photos JPG (Magento 2)

texts: The JPG compression on Magento 2 is very strong, so that the quality of product images get really bad in Catalog and Product view. How can I change the Image compression for JPG's in Magento 2?


texts: I cannot find the local codePool in magento

texts:
I am using magento 1.9 in ubuntu and the code folder does not consist of local .

The Mage.php consist of
Mage.php -

/**
 * Set include path
 */
$paths = array();
$paths[] = BP . DS . 'app' . DS . 'code' . DS . 'local';
$paths[] = BP . DS . 'app' . DS . 'code' . DS . 'community';
$paths[] = BP . DS . 'app' . DS . 'code' . DS . 'core';
$paths[] = BP . DS . 'lib';

but after the command : cd /var/www/html/magento/app/code/
                      : ls
it only shows -->     : community   core

I am stuck in step one http://www.codexpedia.com/magento/create-read-update-and-delete-with-magento-database/
Please Help


texts: How to exclude products from cart price rules? Seems to not work

texts: I tried every combination in both the conditions and action options but I am not getting what I want. Does anybody know how to exclude one or more products from getting a volume discount?


texts: How to update customer_entity table from observer in magento 2.1.9?

texts:
I want to update the "customer_entity" table on adminhtml_customer_save_after event and trying to do so with the help of an observer.
How can i do that?


texts: Magento 2.3 with Varnish: Interval time for health check

texts:
The health check with pub/health_check.php, that is configured in the probe section of the Varnish (version 6) configuration, seems to take a couple of seconds and causes some significant CPU usage. Is this normal or is there anything wrong? I don't know that and I'd like to know what could be expected.

Afaik, the default interval time is set to 5 seconds. Is this a reasonable value or should it be set to another?


texts: what does "displayArea" and "provider" of checkout_index_index.xml mean in magento2

texts: what does displayArea and provider of checkout_index_index.xml mean in magento2?


texts:
I need to refresh the cart page and show a custom block in case my Grand Totals is Negative.

$grandTotal = Mage::helper('checkout/cart')->getQuote()->getGrandTotal();

This prints -$2,269.50, but when I use the below condition, it just don't work.

If ($grandTotal < 0 ){
//do something
}else{
//do something else
}

How can I check if number is less than 0 i.e. negative

Thanks


texts: Magento 1.9.3 Deadlock found when trying to get lock in pdo.php

texts:
I have created a script to import inventory from CSV file. The script is ran with a cronjob that runs every 3 hours. It worked fine until I have a csv file that contains 11000 lines, and I got the following error every time I try to import this csv.

How can I avoid this error?

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction' in /public/lib/Zend/Db/Statement/Pdo.php:228

Stack trace:
#0 /public/lib/Zend/Db/Statement/Pdo.php(228): PDOStatement->execute(Array)
#1 /public/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#2 /public/app/code/core/Zend/Db/Statement.php(291): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#3 /public/lib/Zend/Db/Adapter/Abstract.php(480): Zend_Db_Statement->execute(Array)
#4 /public/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('UPDATE `index_p...', Array)
#5 /public/lib/Varien/Db/Adapter/Pdo/Mysql.php(504): Zend_Db_Adapter_Pdo_Abstract->query('UPDATE `index_p...', Array)
#6 /public/lib/Zend/Db/Ada in /public/lib/Zend/Db/Statement/Pdo.php on line 235


texts: JS Merge vs JS Bundle which one is better for Google ranking

texts:
JS bundling saves page size in MBs but bundled js loaded synchronously. And the browser waits for js download completion.

But in JS Merge Magento merges only those js which are required synchronously. And browser only waits for merged JS which is much lighter than bundled one. And rest of the JS loaded asynchronously.

Somewhere I have seen it is better to load js asynchronously if using HTTP2. And Google also recommends deferring JS.


texts: Programmatically set free shipping from an observer

texts:
I am programming a module where I need to set shipping to be free of charge if certain conditions are satisfied. These conditions are very specific and cannot be modelled using "Shopping cart price rules". The logic to determine whether a user should get free shipping is done but I don't know how to actually make the shipping free. I have tried this:

$address = $quote->getShippingAddress();
$address->setFreeShipping(true);

I am calling this from event handler of checkout_cart_update_items_after

It is based on the freeshipping sales rule that works with data variable free_shipping. However, it does not work. After updating the cart, shipping keeps its nonzero cost.

I have also tried this:

$address = $quote->getShippingAddress();
$address->setShippingMethod('freeshipping_freeshipping');

It works but the problem is that free shipping must be enabled in backend for this to work. That means a user can pick it in checkout anytime - even if he shouldn't get free shipping based on my conditions.

Is there any good way set free shipping from an observer (event handler)?


texts: Collection filter date range not working

texts:
I tried to find the collection that has a range created between 4 hours, but somehow it doesnt show the right collection size, it always returns '0', here's how i use the filter:

$to = date('Y-m-d H:i:s');
$from = date('Y-m-d H:i:s',time() - (3600*4)); //4 hour;
//$from = 2018-04-03 06:29:19;
//$to = 2018-04-03 10:29:19
$collections = $this->mymodel->create()->getCollection()
        ->addFieldToFilter('created_at', ['gteq' => $from])
        ->addFieldToFilter('created_at', ['lteq' => $to]);

here's the data in database:


texts: Deleted tax rules still present on products

texts:
I recently realized that all my tax rules were created 6 times with the exact same name and settings. I have deleted all the duplicates, but for some reason the old rules can still be chosen when editing tax rules per product.

How do I make them disappear completely?


texts: Add another registration form in Magento 1

texts:
I have a registration form on /register and I am trying to add another one for wholesale customers (ie. /register-wholesaler) which should be pretty much the same as the other one just a couple more fields (Business name etc.).

I suppose I need to start with register.phtml...?

Thanks!


texts: Magento 2.3 - How to pass array from controller to template

texts:
I am working on a custom module. I am getting array of attribute values in my custom controller and I want to pass these values in my template to list in a select dropdown. Please provide a solution -

Controller -

<?php

namespace Vendor\Module\Controller\Index;

class Index extends \Magento\Framework\App\Action\Action
{
    protected $_productCollectionFactory;

    public function __construct(
        \Magento\Framework\App\Action\Context $context,
        \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productCollectionFactory
    ) {
        $this->_productCollectionFactory = $productCollectionFactory;
        parent::__construct($context);
    }

    public function execute()
    {
        $Urlparam =  $this->getRequest()->getParam('make');
        echo $Urlparam;
        $objectManager =  \Magento\Framework\App\ObjectManager::getInstance();
        $collection = $this->_productCollectionFactory->create();
        $collection->addAttributeToSelect('id');
        $collection->addAttributeToSelect('model');
        $collection->addAttributeToSelect('status');
        $collection->addAttributeToFilter('status',1);
        $collection->addAttributeToFilter('make',5711);
        //$count =0;
        $modelValues[] = "";
        foreach ($collection as $product) {
            $modelValue = $product->getAttributeText("model");;
            if ((in_array($modelValue,$modelValues)) == false) {
                $modelValues[] = $modelValue;
            }
        }
    }
}

Block file -

<?php

namespace Vendor\Module\Block;

class Vendor extends \Magento\Framework\View\Element\Template
{
    protected $_productCollectionFactory;

    public function __construct(
        \Magento\Backend\Block\Template\Context $context,
        \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productCollectionFactory,
        array $data = []
    ) {
        $this->_productCollectionFactory = $productCollectionFactory;
        parent::__construct($context, $data);
    }

    public function getProductCollection()
    {
        $collection = $this->_productCollectionFactory->create();
        $collection->addAttributeToSelect('id');
        $collection->addAttributeToSelect('make');
        $collection->addAttributeToSelect('status');
        $collection->addAttributeToFilter('status',1);

        return $collection;
    }
}

Template file -

<select class="select-model">
    <option>Select Model</option>
</select>

I am new to this concept. Please provide a solution for how to show the array from the controller in phtml select option.


texts: Magento load subcategory based on dropdown option value

texts:
How to load 2nd dropdown based on 1st dropdown

<!-- Get Parent Category Id Based on Root Category -->

<?php $children = Mage::getModel('catalog/category')->getCategories(2);?>
    <select>
        <?php foreach ($children as $category) {?>
            <option value="<?php echo $category->getId();?>"> <?php echo $category->getName();?></option>
        <?php }?>

    </select>

<!-- Get Parent Category Id Based on Root Category -->

<!-- Get Subcategory -->

    <?php $children = Mage::getModel('catalog/category')->getCategories("**how i load sub category based on 1st dropdown**");?>
    <select >
        <?php foreach ($children as $category) {?>
            <option value="<?php echo $category->getId();?>"> <?php echo $category->getName();?></option>
        <?php }?>

    </select>

<!-- Get Subcategory -->


texts: Magento 2: Override checkout/onepage template of Luma theme

texts:
I have created a custom theme, let say Namespace/customtheme based on Magento/Luma theme and copied onepage.phtml template of Magento_Checkout module in custom theme.

After overriding onepage.phtml, checkout page is not working properly. Block Loader (Magento_Ui/js/block-loader) of checkout page is always showing even the page has been loaded completely.

If I remove the onepage.phtml file from custom theme the it works well.

I have tried to deploy the static content but no luck.

Here is the content of overridden onepage.phtml template:

  app/design/frontend/Namespace/customtheme/Magento_Checkout/templates/onepage.phml

<?php
/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */

// @codingStandardsIgnoreFile
?>

        <img src="<?php /* @escapeNotVerified */ echo $block->getViewFileUrl('images/loader-1.gif'); ?>"
             alt="<?php /* @escapeNotVerified */ echo __('Loading...'); ?>"
             style="position: absolute;">

  Checkout Page

Can someone point me in the right direction? Thanks!


texts: How to get product name,image,short description when add new prodduct & edit product in admin using event

texts: I want to send email when admin add new product or update product having product name, image & short description. Can you know new product or updated product?


texts: How can I get order details of specific product in Magento 2.x?

texts:
I want the detail of orders for a specific product and get the customers detail that which customer had purchased that specified product. How can I know that in Magento 2?

For example: I am having product Chair in my M2 store. I need to know how many orders had been made of that particular product. And how could I know that which customers had purchased that product 'chair'?


texts: Magento 2 :Sort Attributes Alphabetically in layered Navigation

texts:
I want to sort the attributes in layered navigation in the alphabetical order.

http://i.prntscr.com/zDuYTVDbSWqv_507ew0JbQ.png

Sort in the order as:Climate, Color, ...

I tried to override the setPositionOrder() in \Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\Collection using before.

Ref:How to sort layered navigation attributes on Alphabetic order

My magento version is 2.3

But it didn't work. How can I do that? Please help.