texts: Sort by product name not working as expected

texts:
I've bunch of products, Which names start with word "Bai" and afterwards some digits.

  Like, Bai-10, Bai-11, Bai-15 etc.

I've set Default product listing sort by to "use config setting" and at global level I've set it to "Product Name".

When I visit category page, I can see something like this.

Take a look at second row after Bai-10, Bai-14 should come but Bai-103 comes up.

Has anybody faced this type of issue ? Looks like its small thing but I'm not getting it.

Any help would be really appreciated.


texts: Magento ver. 2.4.1 : Can we get order data in Balance Class?

texts:
Is their any way we can get order data
Magento\CustomerBalance\Model\Balance class
In local environment on protected function _ensureCustomer() method i get order data by $this->getOrder() but in live it causes error, i am not sure if $this->getOrder() method exist for this class and in _ensureCustomer() method.
Any advice or thoughts ?


texts: How to override Mage/Core/Model/Domainpolicy.php in a custom module?

texts:
I am trying to override

Mage/Core/Model/Domainpolicy.php

Currently I have done it successfully by copying it to:

app/code/local/Mage/Core/Model/Domainpolicy.php

and added my modifications. That works fine.

But instead I would prefer to have it in my own module which is structured as follows:

app/code/local/Me/Mymodule/

and in its config.xml I have:

<?xml version="1.0"?>
<config>
    <modules>
        <Me_Mymodule>
            <version>0.1</version>
        </Me_Mymodule>
    </modules>
    <global>
        <models>
            <core>
                <rewrite>
                    <domainpolicy>Me_Mymodule_Core_Model_Domainpolicy</domainpolicy>
                </rewrite>
            </core>
            <reports_resource>
                <rewrite>
                    <helper_mysql4>Me_Mymodule_Reports_Model_Resource_Helper_Mysql4</helper_mysql4>
                </rewrite>
            </reports_resource>
        </models>
        <blocks>
            <page>
                <rewrite>
                    <html_head>Me_Mymodule_Page_Block_Html_Head</html_head>
                </rewrite>
            </page>
        </blocks>
    </global>
    <frontend>
        <routers>
            <contacts>
                <args>
                    <modules>
                        <Me_Mymodule before="Mage_Contacts">Me_Mymodule_Contacts</Me_Mymodule>
                    </modules>
                </args>
            </contacts>
        </routers>
    </frontend>
</config>

In app/code/local/Me/Mymodule/Core/Model/Domainpolicy.php I have:

class Me_Mymodule_Core_Model_Domainpolicy extends Mage_Core_Model_Domainpolicy

and the original original code with my modifications applied in one of the functions (I just add a few HTTP headers to the original content policy, no any big changes).

The problem is that when I move the modified Domainpolicy.php inside my module and extend the original class as shown (and it is no longer in app/code/local/Mage) Magento doesn't use it but runs the original one (from app/code/core). At the same time all other things which you see I have overriden in the same module work as expected.

What am I missing?


texts: Magento 2.2.5 Issue when checking value 'Yes' for yes/no attribute

texts:
The following piece of code:

$yesNo = $product->getData('upcoming');
if($yesNo = "Yes") {
    $labels['upcoming'] = 'Upcoming';
}

Is supposed to add a label on products for which the yes/no attribute has been set on 'Yes', but now all products get the label (even those for which the value of the attribute is 'No')

How to correct for this?


texts: Bundle product add to cart issue : Call to a member function getPosition() on a non-object

texts:
I am facing very weird issue on my server while adding bundle product in the shopping cart.Whenever I am trying to add my bundle product, it gives me error like

Fatal error: Call to a member function getPosition() on a non-object in app/code/core/Mage/Bundle/Model/Product/Type.php on line 850.

While debugging in this file ,just find that first magento set it bundle product option and then find its position value .

magento set it option from this line

        $optionsCollection->appendSelections($selections, false, $_appendAllSelections);

from this method.

protected function _prepareProduct(Varien_Object $buyRequest, $product, $processMode)

But magento didn't set it option[Not sure why this occur] and try to get `Position .

Can any one help me to sort out this weired issue ?

Thanks


texts: How to consolidate/summarise/combine color and other attributes in the layered navigation

texts:
we have a lot of clothing and shoes in our magento shop. We use layered navigation to allow the users to shop by color or brand. Everything works fine. However, there is multiple colors which are very similar (chesnut brown, dark brown, brown/black, etc) which should only appear as a single one (in this case just one entry for "brown").

Does anybody know of a plugin or at which part of the code one should tackle that problem? I have googled for hours, but coudln't find anything on that topic. It feels strange that we are the only ones who are interested in that kind of usability optimization. Any kind of hint is appreciated. Maybe we can figure something out together.

Side note: changing the original attributes and products to simpler/normalised versions is NOT an option due to internal/backend stuff.


texts: Magento 2 push event to Google Analytics on register

texts: Has anyone ever pushed an event to Google Analytics when a customer registers? I need to be able to report in GA how many customers for each customer group has registered


texts: Get primary billing / shipping address of customer model

texts:
I got a customer model and want to get the primary billing / shipping address. I tried it like this:

$customerObj->getPrimaryBillingAddress();

$customerObj->getDefaultBillingAddress();

$customerObj->getPrimaryShippingAddress();

$customerObj->getDefaultShippingAddress();

But it just returns bool(false). I am using Magento 1.9 and I am sure, that there is a PrimaryBillingAddress set for the customer.

What am I doing wrong?


texts: \Magento\Backend\Model\View\Result\RedirectFactory already exists in context object. How to solve this problem in magento 2?


texts: remove text from description in bulk for 2319 products

texts:
I imported 2319 products from ebay to magento now i need to change the description in bulk for all the products.

for exemple in descripiton there is <img src="http://www.dropbox.com/xxxxxxxxx">
the xxxxxx part changed from description to description.
this is an issue because the page is not secured any more because of the link!
what can i do to fix it in bulk?


texts:
Whenever I go to my admin site I get:
There has been an error processing your request
Class ******\Testing\Controller\Router does not exist
I have checked the logs, I have redeployed and changed permissions but no luck
any ideas? Thanks


texts: Magento 2 Sign Static Files Showing CSS/JS 404 Error in SEO Reports

texts:
I am using Version Number In File Paths in Magento 2, but it's showing 404 errors in SEO reports after run Magento deploy command because of deploy command change version number every time

I have also added below code in Robots.txt file

`Disallow: /pub/static/`

But still, it's showing in 404 errors in SEO reports. I can't disable Sign static files function from the admin side.

Please let me know how can we solve this issue.


texts: What to notice when migrating from Magento CE to EE?

texts:
I developed two modules for Magento CE 1.9.0.1. Now our customer decides to migrate to Magento EE 1.14.0.1. They bought it and I installed the extensions and tested them. They worked with zero problems.

But my development on the extensions is not finished yet and I have to enable some more functionality to them. Now here's the questions:

I certainly don't think "seeing" the extension works with no problem is the way to migrate the extension from CE to EE. I think there should be a more reliable way to do this. So from where (or how) could I make sure that my extension works completely well on Magento EE?
In more general, what are the differences between Magento CE and EE? Is there anything that extension developers should notice when they're migrating an extension? I could not find anything useful on the web that explains the differences.

Thanks.


texts:
Good afternoon,
We are trying to remove the special price via the API.
When the option "Use Default Value" is disabled you are able to change the price.
When this setting is enabled we are not able to update. See setting below.

For our first website this setting is disabled by default.
We are not able to understand this setting. Is it somehow possible to disable this setting for all websites and products.
We are not getting any feedback from the request, that's just executing.
Thanks for helping us out.
Kind regards,
Pascal


texts: I would like to upgrade to the Magento's latest version and latest version of theme. I know very about coding. What do I need to do?


texts: Problem when enabling production mode on magento 2

texts:
I've installed an extension via ssh on magento 2, compiled and everithing is ok.
The problem is that when enabling production mode i have the error in the image.
Any thoughs? Let me know if you need more information, thank you (magento 2.2.4)


texts: Should we update mySQL and Maria in Magento 2.2?

texts:
I am getting messages from our server that we need to update the installation of MySQL and possibly install Maria.  (MySQL 5.6 to 5.7) Problem is that we are on a self hosted VPN and the server company will not do the upgrade on an adhock payment basis and our developer will not touch the server.  (he only works on Magento).  I can't seem to find any information on whether or not this upgrade will work with Mag 2.2 but I am finding warnings that the Maria install can corrupt databases and that Magento may or may not work with it.

So.....can anyone tell me if Mag 2.2 is better off with or without Maria?  As well, are there any developers that are willing to work on a fixed price basis to do the back up and the upgrade?

Thanks


texts: Connection Error try again later - Magento connect not working

texts:
I am struggling from last week to install an extension using Magento connect, but it is not working so far. When I tried to installed SMTP Pro, the progress circle keeps running for atleast 5 mins and thereafter gives error "Connection Error try again later". So I tried to install another extension but no one getting installed. So definitely there is a problem with Magento connect manager.

I tried all the solution available here or anywhere on the internet but nothing is serving the purpose.

Just wanted to know if there is any option to trace the problem.


texts: Avoid Magento 2 from automatically adding tax rate to uploaded gross prices

texts:
I upload my prices as gross prices incl. all taxes.

Still I want the invoice to show the tax rate without Magento adding it automatically during checkout.
I need Magento to understand my product prices as gross prices, not as net prices. Same applies for shipping prices.

Example:

product price: 10

tax rate: 10%

Magento total: 11

What I need:

product price: 10

tax rate: 10%

Magento total: 10

(invoice showing: product price: 9.09, tax rate: 10%, total price: 10)

Basically as it is in any other shop. Shown are the gross prices that include tax but the invoice shows the net price + tax which then is the total price (the one I uploaded for the product).


texts: M2 | Can we create one field by dataprovider and one field by uicmponent in single group at Product Creation Page?

texts:
I have created toggle button by uicomponent in one group and some other fields by dataprovider way in another group.

Can I get toggle button into group created by dataprovider way. As it is not possible toggle checkbox to be created without uicomponent.


texts: Magento 2: Import Script Store Id Related Issue

texts:
I'm using Magento 2 CE Version 2.1.3

Magento 2: Save all product data outside Magento with Images

Once I imported data from CSV using above script.

If put as ->setStoreId(0), then it will add two values for same Field In Database Table. One as Store Id 0 & Second As Store Id 1.

Example: catalog_product_entity_varchar

value_id    attribute_id store_id entity_id     value
100           70           0       10           Test
101           70           1       10           Test <- NOT NEEDED ENTRY

attribute_id 70 is for name (Product Name) from Table eav_attribute

Due to 2 values for Same Field. Each time have to delete Store Id 1 related value from Database respective Table, then it works fine on Frontend.

At the end data is not displaying properly as needed. Have to do each time Delete Query for Store Id in 5-6 tables.

Go to Admin -> Stores -> Configuration -> General -> General -> Single Store Mode

It always been issue. On Admin side it's taking Store Id 0 value & on frontend displays it's taking Store Id 1 Value.

  Enable Single-Store Mode set to "Yes"

On Admin -> All Store Views -> Store Id = 0 -> Admin Using This
On Admin -> Default Store Views -> Store Id = 1 -> Frontend Using This

What i'm still missing in Script? Does Enable Single-Store Mode set to "Yes" helps?

Other workaround will be set Admin to Default Store Views. In my case i have only 1 store. So may be works.

While we do Default Magento Import/Export. It only uses Store Id 0  & it works fine.


texts:
I want to create new mass action inside Order grid which will create new Shipment but I have problem with my action. When I click submit button my action don't work but only redirect me on homepage.

My app/code/local/CFO/ShipAction/etc/config.xml

<config>
<modules>
    <CFO_ShipAction>
        <version>0.1.0</version>
    </CFO_ShipAction>
</modules>
<admin>
    <routers>
        <cfoshipaction>
            <use>admin</use>
            <args>
                <module>CFO_ShipAction_Adminhtml</module>
                <frontName>cfoshipaction</frontName>
            </args>
        </cfoshipaction>
    </routers>
</admin>
<adminhtml>
    <events>
        <core_block_abstract_prepare_layout_before>
            <observers>
                <CFO_ShipAction_Model_Observer>
                    <type>singleton</type>
                    <class>CFO_ShipAction_Model_Observer</class>
                    <method>addShipAction</method>
                </CFO_ShipAction_Model_Observer>
            </observers>
        </core_block_abstract_prepare_layout_before>
    </events>
</adminhtml>
</config>

My  app/code/local/CFO/ShipAction/Model/Observer.php

class CFO_ShipAction_Model_Observer
{
    public function addShipAction($observer){
        $block = $observer->getEvent()->getBlock();
        if(get_class($block) =='Mage_Adminhtml_Block_Widget_Grid_Massaction'
            && $block->getRequest()->getControllerName() == 'sales_order')
        {
            $block->addItem('cfoshipaction', array(
                'label' => 'Create shipment',
                'url' => Mage::app()->getStore()->getUrl('cfoshipaction/adminhtml_massactions/createShipment')
            ));
        }
    }
}

And app/code/local/CFO/ShipAction/controllers/Adminhtml/MassActionsController.php

require_once 'Mage/Adminhtml/controllers/Action.php';

class CFO_ShipAction_Adminhtml_MassActionsController extends Mage_Adminhtml_Controller_Action {
    public function createShipmentAction() {
        $orderIds = $this->getRequest()->getPost('order_ids', array());
            foreach ($orderIds as $orderId){
                try {
                    $order = Mage::getModel('sales/order')->load($orderId);
                    if($order->canShip()) {
                        //Create shipment
                        $shipmentid = Mage::getModel('sales/order_shipment_api')
                                        ->create($order->getIncrementId(), array());
                        //Add tracking information
                        $ship = Mage::getModel('sales/order_shipment_api')
                                        ->addTrack($order->getIncrementId(), array());
                    }
                }catch (Mage_Core_Exception $e) {
                    print_r($e);
                }
            }
            $this->_redirect('adminhtml/sales_order/');
    }
}

I'm know that problem is with my router, but I don't know where. I tried 2 options for initializing my router but both not help. Can anybody see what's missing? Thanks!

EDIT:

There is my other config.xml with other router which I've tried to use but sill noting:

<config>
...
<admin>
    <routers>
        <adminhtml>
            <args>
                <CFO_ShipAction before="Mage_Adminhtml">CFO_ShipAction_Adminhtml</CFO_ShipAction>
            </args>
        </adminhtml>
    </routers>
</admin>
...
</config>

Thanks for help !


texts:
In Magento 1.x I used to use

Mage::log();

I need the same function for Magento 2


texts: How to get welcome text in template(Magento 1.9)

texts:
How I can get fetch the welcome text of Configuration in Template file.

For e.g. welcome text : "Free shipping above $3"

It is located under System/Configuration/design/header


texts: How do I create a non-editable Magento CMS Page?

texts:
On a fresh installation of Magento, it comes with several default CMS pages that you can edit in CMS > Pages. However, it also comes with a couple of "non-editable" CMS Pages: Orders and Returns and Contact Us... both of which are pages with forms on them, and highlights a shortcoming in Magento CE: creating and editing forms.

I have managed to override the default Contact Us with my own form, but I would like to add another form, and may need to add more forms in the future. I am somewhat familiar with creating Magento Modules to override existing functions and pages, as I've done thus far.

I have started working on a module that would enable the ability to create form pages in Magento, but they have to be invisible to the CMS management like the default forms are. I have found answers to programmatically creating a CMS page, but that adds it to Magento's CMS > Pages.

How do I create a CMS page that is only editable by a Magento Module?


texts: Call sales order model inside console command object

texts:
After ugprade to M2 2.2.4, I got problem in my custom module. The module has console command but upon upgrade I'm getting "Area code is not set". After few hours of debugging, I found out that the root cause is calling \Magento\Sales\Model\Order object as parameter in my __Construct function.

Replacing it with reourceModel will work, but I'm just wondering why the main order model is not working. Any idea?


texts: Magento2: issue with bulk actions update - not started

texts:
After upgrade to Magento 2.4 I have issue with bulk update attributes.
57567f7a-e3ec-4812-a6e1-0b3861c06540    Jan 2, 2021 9:27:26 PM  Update attributes for 13898 selected products   Not Started

cron is running correct - because correct export products feed, running reindex etc.
I check in our second website store on M2.4 and the same issue.
Only issue with  mass update products attributes.
Has anyone encountered such a problem and do you have a solution?


texts: Magento 2: Best way to change customer group event & call if needed?

texts:
Trigger event after an order has been created/saved

<event name="sales_order_place_after">
    <observer name="change_user_group" instance="Custom\Module\Observer\ChangeUserGroupObserver" />
</event>

We have 2 events sales_order_place_after or checkout_onepage_controller_success_action.

What if user has refreshed the success page & if group is already changed then i don't want to call that observer.

It should not go to observer file itself.

Can we put like if condition on events.xml? What is alternative?


texts: Magento2 Use Prefence and Plugin both in single di.xml

texts:
For override two files in magento2 one using with prefence and other using plugin ,can we do this in single di.xml file

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
     <preference for="Magento\Checkout\CustomerData\DefaultItem" type="Vendor\module\CustomerData\DefaultItem" />

     <type name="Magento\Checkout\Model\DefaultConfigProvider">
        <plugin name="default_config_provider" type="Vendor\module\Model\DefaultConfigProvider"/>
    </type>
</config>

I was using this but its not working.Please help me.


texts: After Ajax Customer Login when add product to cart show Invalid form message error

texts:
I'm developing a module for the customer be able to login from any page by ajax. Its working but when the customer log in, all the forms are invalid. My module in any moment redirects the browser, I now that if I reload the page after the successful ajax login it works normally. But is there a way to by pass this without reloading the page?
In my module when login is successful it automatically update the minicart and other things once I use this configuration in my sections file:
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Customer:etc/sections.xsd">

<action name="ajaxlogin/customer/login">

</action>


texts: Magento 2: phtml page adding buttons and pop up models

texts:
Is it possible to add a few buttons and once the user clicks get pop up model which built by Magento 2?
I want to allow the user to click a button and display a pop-up
I was thinking to add 2/3 buttons and different content for each pop-up


texts: Where to find Magento Configuration files

texts:
I'm trying to change a default setting in Magento, and I have found the solution how to change it.

The issue is I can't find the file, I need to modify items.phtml.

The path is app/design/adminhtml/default/default/template/sales/order/shipment/create/items.phtml. But I think the post was for Magento 1, I'm not 100% sure.

Where I can find the items.phtml file?

I am trying to set the Email Copy of Shipment as "Checked" as default. Please see the attached screenshot.

I found an old post where a person wanted to achieve the same and was provided this ( I found out later that the post was 9 years old):

    __('Email Copy of Shipment') ?>

When created the "items.phtml" and did what was suggested in the comments nothing changed.

I did run after i inserted the file. : php bin/magento setup:upgrade and deploy, Cleared cache and re indexed.

Any help with this is appreciated.


texts: Magento 2 error: lock wait timeout exceeded. query was: update session set session expired =?

texts:
Some of my customers get this error randomly. And there are sleep query commands in mysql with no info.
How can I solve this?


texts: Server Load Average Extremely High - 35.46, 36.08, 36.35

texts:
I'm running a Digital Ocean droplet with 32GB Memory which runs an online store that uses Magento as a CMS/ERP.

Lately I've noticed that the load average for the droplet is extremely high, sometimes the 1 minute spike goes up to 60, but even more scary is that the 15 minute average as been around 40.

Site traffic is around 150 users at any given time, which is pretty standard.

php-fpm processes seem to be the cause, and my guess is it's due to a module that's loaded in Magento where PHP pulls all the products for a category. Another reason I think this may be the cause is as seen in the image below, the processes are using high cpu but low memory, so maybe a DB query?

I checked the php-fpm status page and all the listings just specify the index.php because that's the entry point for the Magento app.

There is one sale category called "All Sale" which the e-commerce team has been pushing lately, and added about 400 products to it. Each of these products has configurable options for colours and sizes. Also, it displays every product in a mass listing, not in batches. I checked the site traffic and nearly half of it was in this category. My guess would be that when they added all these products to the category, and then marketed the sale, traffic increased, and the DB queries for all of these configurable sale items eats up the CPU, causing the entire web store to go slower.

We do have varnish caching and magento caching set-up, so once a new visitor has visited this category, it "appears" to go a lot faster.

I should also mention that our DB is hosted on a separate droplet from the web store, could this increase the load average as it has to access the DB remotely for each query?

Am I correct in assuming this is the cause in the high load average? If I am correct in assuming this is the cause, is there any way to increase performance for this type of situation?


texts: "Class mixed does not exist" with only one array param in the body in Magento 2

texts:
I have a custom Magento 2 PUT request that looks like:

<route method="PUT" url="/V1/items">
    <service class="Vendor\Items\Api\ItemsManagementInterface" method="replaceItems" />
        <resources>
            <resource ref="self" />
    </resources>
 </route>

Class interface:

/**
 * Description
 *
 * @param mixed $items
 * @return string
 */
public function replaceItems($items);

The request works with this JSON body payload:

{
  "items": [
    "url1",
    "url2"
  ],
  randomParam: true
}

Instead, an error is trown if the payload is just:

{
  "items": [
    "url1",
    "url2"
  ]
}

The full error returned from Magento REST Api:

  {
          "message": "Class mixed does not exist",
          "code": -1,
          "trace": "#0 vendor/magento/framework/Reflection/MethodsMap.php(155): ReflectionClass->__construct('mixed')
  #1 vendor/magento/framework/Reflection/MethodsMap.php(106): Magento\Framework\Reflection\MethodsMap->getMethodMapViaReflection('mixed')
  #2 vendor/magento/module-webapi/Controller/Rest/ParamsOverrider.php(203): Magento\Framework\Reflection\MethodsMap->getMethodsMap('mixed')
  #3 vendor/magento/module-webapi/Controller/Rest/ParamsOverrider.php(147): Magento\Webapi\Controller\Rest\ParamsOverrider->isPropertyDeclaredInDataObject('GV\\Products\\Api...', 'replaceItems...', 'items')
  #4 vendor/magento/module-webapi/Controller/Rest/InputParamsResolver.php(93): Magento\Webapi\Controller\Rest\ParamsOverrider->overrideRequestBodyIdWithPathParam(Array, Array, 'Vendor\\Items\\Api...', 'replaceItems...')
  #5 vendor/magento/module-webapi/Controller/Rest.php(322): Magento\Webapi\Controller\Rest\InputParamsResolver->resolve()
  #6 vendor/magento/module-webapi/Controller/Rest.php(239): Magento\Webapi\Controller\Rest->processApiRequest()
  #7 vendor/magento/framework/Interception/Interceptor.php(58): Magento\Webapi\Controller\Rest->dispatch(Object(Magento\Framework\App\Request\Http))
  #8 vendor/magento/framework/Interception/Interceptor.php(138): Magento\Webapi\Controller\Rest\Interceptor->___callParent('dispatch', Array)
  #9 vendor/magento/framework/Interception/Interceptor.php(153): Magento\Webapi\Controller\Rest\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
  #10 generated/code/Magento/Webapi/Controller/Rest/Interceptor.php(39): Magento\Webapi\Controller\Rest\Interceptor->___callPlugins('dispatch', Array, Array)
  #11 vendor/magento/framework/App/Http.php(135): Magento\Webapi\Controller\Rest\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
  #12 generated/code/Magento/Framework/App/Http/Interceptor.php(24): Magento\Framework\App\Http->launch()
  #13 vendor/magento/framework/App/Bootstrap.php(256): Magento\Framework\App\Http\Interceptor->launch()
  #14 index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http\Interceptor))
  #15 {main}"
      }

I have already recompiled the DI and flushed the cache.

Also tried in the class interface: mixed[], string[], etc..

Goal: being able to make a request passing only a single array parameter, without the need to also pass a second param.


texts: Magento 1 - How to show bundle products original price and discount price in product listing page

texts: Am creating a Combo Offer using Bundle option in my store. I did everything, but need to show Original Price and Special price in product list page. Eg:


texts: Move navigation.sections into the page.header element in XML?

texts:
This is my code:

    <move element="navigation.sections" destination="page.header" />

But the navigation bar disappears then. Whats wrong here?


texts: Is there an event for apply coupon action in cart

texts:
I want to add a product to cart automatically when a coupon is applied. When the coupon is applied the product should be added to cart showing its price and a discount of the price of the product needs to be applied.

What I tried is created a coupon code which offers a fixed amount discount which is the price of the product that I want to add to cart. And then I observed the event salesrule_validator_process to check the coupon code applied and tried to add the product to cart. But when the coupon is applied in the cart the above event is fired thrice, so 3 quantities of the product is added to cart. Also every time the cart page is refreshed 2 quantities of the product is again added to cart.

EDIT :
How do I remove the product from cart when the coupon is cancelled.

Is there any event which gets fired only once when the coupon is applied or is there any other better method to attain what I want?


texts: Magento 2: Two Prices for the same product

texts:
I was wondering does anyone know if Magento 2.2.6 is capable of handling more than one price for each product.

The reason I ask is that I buy in most of the items we sell after they have been ordered. Our suppliers have different prices for shipping to us. Next day which is the most expensive and a cheaper price which takes 4 days for the items to arrive with us.

I am looking to include shipping within the price on the product page and as I have two different prices I would like our customers to see them immediately without having to add to basket and find how much it is at that stage. Is there any extensions or has anyone seen this functionality implemented elsewhere?


texts: Updating ui_bookmark Table When Adding Columns via ui_component XML

texts:
In Magento 2, the ui_component based grids allow you to reorder columns and Magento will remember your settings the next time you log in.  This is accomplished by Magento saving data in the ui_bookmark table (via a Magento\Ui\Model\Bookmark model object).

While this feature it neat, it can create problems when a extension developer or system integrator uses Magento ui_component XML to add columns to a table.  If there's a custom data ui_bookmark then Magento will (seemingly) ignore the sort order of a new column and weird/unexpected things can happen.

Is there a best practice and/or system for extension developers who want to add columns to a UI Grid (either Magento's or their own) and ensure a column is somewhere in relation to the others?  i.e. -- "This second action button should always appear last, or always appear second last", or "the name field should always be after ID.

Does an extension developer need to, via an app/code/Package/Module/Setup/... class, reach into the ui_bookmark table and update these entries themselves?  Or is there a better way to accomplish this?  Or do extension developers just need to live with a column being added to unexpected places when a user already has an entry in ui_bookmark?


texts: Magento 2, programmatically create configurable products

texts:
Hello I have the necessity of creating both simpe and configurable products.
This is what (following online guidelines) I have right now:
$bootstrap = Bootstrap::create(BP, $params);
$objectManager = $bootstrap->getObjectManager();
$state = $objectManager->get('Magento\Framework\App\State');
$state->setAreaCode('frontend');
$salt = rand(10, 999);

//REGARDING SIMPLE PRODUCTS
$simple_product = $objectManager->create('\Magento\Catalog\Model\Product');
$simple_product->setSku('test-simple' . $salt);
$simple_product->setName('test name simple' . $salt);
$simple_product->setAttributeSetId(9); //my own attribute set

$simple_product->setData('157', '9'); // my custom attribute flavor and it's assigned value

$simple_product->setStatus(1);
$simple_product->setTypeId('simple');
$simple_product->setPrice(10);
$simple_product->setWebsiteIds(array(1));
$simple_product->setCategoryIds(array(14)); //it's category
$simple_product->setStockData(array(
    'use_config_manage_stock' => 0, //'Use config settings'?
    'manage_stock' => 1, //manage stock
    'min_sale_qty' => 1, //Minimum Qty Allowed in Shopping Cart
    'max_sale_qty' => 2, //Maximum Qty Allowed in Shopping Cart
    'is_in_stock' => 1, //Stock Availability
    'qty' => 100 //qty
    )
);
$simple_product->save();

$productRepository = $objectManager->get('\Magento\Catalog\Api\ProductRepositoryInterface');
$product = $productRepository->getById($simple_product->getId());
$product->setFlavor('BBBB');  //my custom attribute is called flavor and BBBB it's is value
$product->getResource()->saveAttribute($product, 'flavor');

$simple_product_id = $simple_product->getId(); //get ID
echo "simple product id: ".$simple_product_id."\n";

This works just perfect, now I'd like to create a configurable product and assign this product to it:
//REGARDING CONFIGURABLE PRODUCTS
$configurable_product = $objectManager->create('\Magento\Catalog\Model\Product');
$configurable_product->setSku('test-configurable' . ++$salt);
$configurable_product->setName('test name configurable' . ++$salt);
$configurable_product->setAttributeSetId(9);
$configurable_product->setStatus(1);
$configurable_product->setTypeId('configurable');
$configurable_product->setPrice(11);
$configurable_product->setWebsiteIds(array(1));
$configurable_product->setCategoryIds(array(14));
$configurable_product->setStockData(array(
    'use_config_manage_stock' => 0,
    'manage_stock' => 1,
    'is_in_stock' => 1,
    'qty' => 999
    )
);

$configurable_product->getTypeInstance()->setUsedProductAttributeIds(array(157),$configurable_product); //attribute ID of attribute flavor

$configurableAttributesData = $configurable_product->getTypeInstance()->getConfigurableAttributesAsArray($configurable_product);

$configurable_product->setCanSaveConfigurableAttributes(true);
$configurable_product->setConfigurableAttributesData($configurableAttributesData);

$configurableProductsData = array();
$configurableProductsData[$simple_product_id] = array( //our simple product ID
    '0' => array(
        'label' => 'gusto', //attribute label
        'attribute_id' => '157', //attribute ID of attribute 'flavor' in my store
        'value_index' => '9', //value of 'BBBB' index of the attribute
        'is_percent'    => 0,
        'pricing_value' => '10',
    )
);

$configurable_product->setConfigurableProductsData($configurableProductsData);

$configurable_product->save();

echo "configurable product id: ".$configurable_product->getId()."\n";

I successifully create both products, but the simple is not associated with the configurable one.
Of course I do something wrong.... can you please guide me in the right direction?


texts: How to find out If Magento MySQL is hosted on AWS RDS

texts: How do I find out if my Magento Instance's Database is being hosted on RDS? I see a RDS instance on AWS, but am not sure how I test without actually stopping the RDS. Wondering if there's a more elegant way to determine.


texts: How to inject Magento 2 commands in custom command?

texts:
To whom may concern,

As the title said, I'm wondering is there anyway to inject/call/execute Magento default commands in my custom command?

I'm just another guy who living in Terminal world and I'm exhausted while have to press ↑ then Enter for those commands all day.

At this moment, I'm forced to write a bash script to shorten it. So I think it is better if I wrote a custom command of Magento 2 to do those jobs. Then I can just simple use bash alias that command in my way.

For example:

I need to execute setup:upgrade, rm -rf var/generation var/di, setup:di:compile in just only one command and few more thing (actually a lot) after setup:di:compile executed successfully.

setup:upgrade is handled by this class \Magento\Setup\Console\Command\UpgradeCommand

setup:di:compile is handle by this one \Magento\Setup\Console\Command\DiCompileCommand

But I'm not sure is it Ok to call execute() method in my custom command?

Anyone have any ideas for this situation?


texts:
I don't understand what the gallery attribute does? I've imported products and images. The images were imported into an attribute called gallery but they don't show up in the admin or on the front-end. They only show if they're placed inside the catalog_product_media_gallery table. So, what is the gallery attribute for and why did Magento put my images into that field?

Thanks!


texts: Coupon code - cap amount on which a % discount applies

texts:
So I'm trying to setup a new coupon in Magento Shopping Cart Price Rules but I can't make it work as wanted. If you have any ideas, here's what it should do :

Coupon A should give 8% discount up to a 400€ cart value. So it's basically caped to 32€ BUT the customer should still be able to get the 32€ discount when his cart is above 400€.

Right now if I cap the cart value to 400€ then the coupon just becomes invalid when the cart value exceeds that amount.


texts: Magento 2 - Can't seem to upgrade to 2.0.3

texts:
Today 2.0.3 was released and we've been trying out some Magento 2 installations on a development VPS.

There are multiple installations, but I can't seem to upgrade any of them.

At first we had some issues with the deployment, but after that had settled, every installation acts the same:

We open System > Web Setup Wizard and select System Upgrade.

After a few moments all we see is a error-box saying

  Sorry, we can't take that action right now

With no further errors/logs (nor in the console or syslogs).

I tried to do the same in production mode, hoping that would amount to anything, but alas..

Anyone else has problems running this update? Magento 2 has been a tough nut to crack so far with the server-settings and all, but we've managed to get it rolling smoothly, so I wonder why this isn't working.

Any ideas where to look for answers?


texts: Display a different message for virtual products in cart

texts:
I'm trying to display a message for virtual products in the cart that they will be processed in 1 to 3 days. I got this to display but it is also displaying the standard message treating it as a backorder.

Here is a portion of my default.phtml

<?php $_product = $this->getProduct() ?>
    <?php if ($_product->getTypeId() == "virtual"): ?>

<?php echo $this->__('Item will be processed in 1 to 3 business days') ?>

    <?php endif; ?>
    <?php if ($messages = $this->getMessages()): ?>
    <?php foreach ($messages as $message): ?>
        <p class="item-msg <?php echo $message['type'] ?>">* <?php echo $this->escapeHtml($message['text']) ?>

    <?php endforeach; ?>
    <?php endif; ?>

How can I modify the above code to only show virtual products one message and other products the standard backorder message?


texts: How to override core class which is already overrided by other custom module in Magento 2

texts:
How to override core class which is already overrided by other custom module

I have module1 and module2 overriding CatalogSearch module.

in Module1

etc/di

<preference for="Magento\CatalogSearch\Controller\Result\Index" type="Vendor\Module1\Controller\Result\Index" />

in Controller class

class Index extends \Magento\CatalogSearch\Controller\Result\Index
{
 public function __construct(
    Context $context,
    Session $catalogSession,
    StoreManagerInterface $storeManager,
    \Magento\Framework\View\Result\PageFactory $resultPageFactory,
    Resolver $layerResolver,
    QueryFactory $queryFactory

) {
     parent::__construct($context,$catalogSession,$storeManager,$resultPageFactory,$queryFactory,$layerResolver);
     $this->resultPageFactory = $resultPageFactory;
     $this->layerResolver = $layerResolver;
     $this->_queryFactory = $queryFactory;
     $this->_storeManager = $storeManager;
}

In Module2

etc/di

<preference for="Vendor\Module1\Controller\Result\Index" type="Vendor\Module2\Controller\Result\Index" />

In Controller class

 class Index extends \Vendor\Module1\Controller\Result\Index
 {
    public function __construct(
    Context $context,
    Session $catalogSession,
    StoreManagerInterface $storeManager,
    Http $request,
    LayoutInterface $layout,
    ScopeConfigInterface $scopeConfig,
     Resolver $layerResolver,
    \Magento\Catalog\Model\CategoryFactory $catalogCategoryFactory,
    \Magento\Framework\Registry $registry,
    \Vendor\Module1\Model\Client\Connector $tglssearchClientConnector,
    QueryFactory $queryFactory,
    \Magento\Framework\View\Result\PageFactory $resultPageFactory
) {
    parent::__construct($context,$catalogSession,$storeManager,$queryFactory,$layerResolver);
        $this->_storeManager = $storeManager;
        $this->catalogSession = $catalogSession;
        $this->storeManager = $storeManager;
        $this->request = $request;
        $this->layout = $layout;
        $this->scopeConfig = $scopeConfig;
        $this->catalogCategoryFactory = $catalogCategoryFactory;
        $this->registry = $registry;
        $this->tglssearchClientConnector = $tglssearchClientConnector;
        $this->layerResolver = $layerResolver;
        $this->_queryFactory = $queryFactory;
        $this->resultPageFactory = $resultPageFactory;

    /* parent::__construct(
        $context
    ); */
}

I get below error,

  Argument 4 passed to Vendor\Module1\Controller\Result\Index::__construct() must be an instance of Magento\Framework\View\Result\PageFactory, instance of Magento\Search\Model\QueryFactory given, called in C:\xampp\htdocs\magento2x_5test\app\code\Vendor\Module2\Controller\Result\Index.php on line 36 and defined in C:\xampp\htdocs\magento2x_5test\app\code\Vendor\Module1\Controller\Result\Index.php on line 22


texts:
To start I have already modified the check/money order payment method to be available only in admin (That worked, but not via the API)

The problem is that the method is not available to the V1 API.
Here is how I am setting the cart

$cart = $proxy->call( $sessionId, 'cart.create', 0);

(Store 0 is Admin)

$result = $proxy->call($sessionId, "cart_payment.list", array($cart));

Where I get my list of methods only those available on the frontend are working. What I need is a method that is only available via the API.


texts: How to get all information for a product in magento?

texts:
I.m trying to get all information for magento catalog products.
I've tried

$product = Mage::getResourceModel('catalog/product_collection');

but I want to get all attributes for that product( categoryIds is one of them).


texts: Adding an additional menu item to a product in Magento 2

texts:
I'm creating an extension and I'm wondering how to add a new menu item to a product view next to "Content", "Configuration", "Product Reviews", "Images and Vidoes" etc.

I've been studying the code in /vendor/magento/module-catalog/view/adminhtml/layout/catalog_product_form.xml to create a catalog_product_form.xml in my module's view/adminhtml/layout directory, but the new menu item never shows.

I've added new columns to the admin product grid, and new configuration items via the system.xml file, so I think I understand how the DOM merging should work, but what am I don't wrong with this product menu item? Here's the code in my module's catalog_product_form.xml:

<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_layout.xsd">
    <referenceContainer name="product_form">
        <block name="gallery" class="Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Gallery">
            <arguments>
                <argument name="config" xsi:type="array">
                    <item name="label" xsi:type="string" translate="true">My experiment</item>
                    <item name="collapsible" xsi:type="boolean">true</item>
                    <item name="opened" xsi:type="boolean">false</item>
                    <item name="sortOrder" xsi:type="string">22</item>
                    <item name="canShow" xsi:type="boolean">true</item>
                    <item name="componentType" xsi:type="string">fieldset</item>
                </argument>
            </arguments>
            <block class="Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Gallery\Content" as="content">
                <arguments>
                    <argument name="config" xsi:type="array">
                        <item name="parentComponent" xsi:type="string">product_form.product_form.block_gallery.block_gallery</item>
                    </argument>
                </arguments>
                <block class="Magento\ProductVideo\Block\Adminhtml\Product\Edit\NewVideo" name="new-video" template="Magento_ProductVideo::product/edit/slideout/form.phtml"/>
            </block>
        </block>
    </referenceContainer>
</layout>


texts: Template file is not running In Magento?

texts:
Hello I am new to Magento & using Magento 2.1.7. I was learning to develop custom module. My module is working till the controller but it is not printing the data present in the template file named blockContent.phtml.

My Code:

  App/Code/Funky/Hello/Controller/Path/HelloWorld.php

<?php

namespace Funky\Hello\Controller\Path;

use \Magento\Framework\App\Action\Action;
use \Magento\Framework\App\ResponseInterface;
use \Magento\Framework\View\Result\PageFactory;
use \Magento\Framework\App\Action\Context;

class HelloWorld extends Action
{
    protected $pagefactory;
    public function __construct(Context  $context, PageFactory $pageFactory)
    {
        $this->pagefactory=$pageFactory;
        Parent::__construct($context);
    }
    /**
     * Dispatch request
     *
     * @return \Magento\Framework\Controller\ResultInterface|ResponseInterface
     * @throws \Magento\Framework\Exception\NotFoundException
     */
    public function execute()
    {
        echo "testing? is working";
        return $this->pagefactory->create();

    }
}

  App/Code/Funky/Hello/Block/Main.php

<?php
namespace Funky\Hello\Block;
use \Magento\Framework\View\Element\Template;

class Main extends Template
{
    public function _prepareLayout()
    {

    }

}

  App/Code/Funky/Hello/etc/frontend/route.xml

<?xml version="1.0"  ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation=
        "urn:magento:framework:Module/etc/routes.xsd">
    <router id="standard">
        <route id="funky" frontName="funky">
            <module name="Funky_Hello"/>
        </route>
    </router>
</config>

  App/Code/Funky/Hello/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="Funky_Hello" setup_version="0.0.1"/>
</config>

  App/Code/Funky/Hello/view/frontend/layout/funky_path_helloworld.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation=
        "urn:magento:framework:View/Layout/etc/page_configuration.xsd">

        <referenceContainer name="columns.top">
            <block class="Funky\Hello\Block\Main"
                   template="workin.phtml"
                   name="funky_hello_Hell"/>
        </referenceContainer>
        <referenceContainer name="content">
                <block class="Funky\Hello\Block\Main"
                       template="Funky_Hello::blockContent.phtml"
                       name="funky_hello_HelloWorld"/>
        </referenceContainer>

</page>

  App/Code/Funky/Hello/view/frontend/layout/templates/blockContent.phtml

Hello World!

It is working or not???

<?php echo "nothing is happening why? ";?>

I have also created the registration.php.
If any one can tell me what  exactly I am doing mistake?
Thank you in advance.


texts:
we used some marketplace extension , so

here in this following link, you can see only 1 product is displaying per row.

i want to display 3 products per row .

http://hotwheelstoys.in/totaltoys2/var/www/html/totaltoys/marketplace/seller/collection/kidsdial2

is there any css problem with that page as it is displaying only one per product per row?

please help me to display 3 products per row and help me to display "add to cart" button below as like here :

http://hotwheelstoys.in/totaltoys2/var/www/html/totaltoys/girls-toys.html

thanks in advance


texts: Can you create a background picture in a single static page in M2 (404)?

texts:
I'm wanting to edit my 404 static page content and simply add a background image across the whole viewable pane.

Is there a way to do with in M2.1 ?


texts: Fetching product url and remove product from cart

texts:
The following is code

$itemsCollection = Mage::getSingleton('checkout/session')->getQuote()->getItemsCollection();

// get array of all items what can be display directly
$itemsVisible = Mage::getSingleton('checkout/session')->getQuote()->getAllVisibleItems();

// retrieve quote items array
$items = Mage::getSingleton('checkout/session')->getQuote()->getAllItems();

foreach($items as $item) {

    echo '
';
    echo ''.$item->getQty().'';
    echo 'getUrl().'">'.$item->getName().'';
    echo ''.$item->getPrice().'';
    echo ''.$item->getRemoveUrl().'';
    echo '
';

}

Everything is fine but '.$item->getUrl().' and '.$item->getRemoveUrl().' are not working. Any help will be appreciated.


texts: How do I reset administrator Role permissions

texts: If you have managed to loose your role permissions, like this: How do I reset Magento Admin User Role


texts:
I have downloaded and installed Magento 2 but I'm getting 404 error for scripts and css. An example of my image path is: http://www.arredomobilionline.com/pub/static/frontend/Magento/luma/it_IT/images/logo.svg

I've already tried this solution:

  Open up app/etc/di.xml and find the virtualType
  name="developerMaterialization" section. In that section you'll find
  an item name="view_preprocessed" that needs to be modified or deleted.
  You can modify it by changing the contents from
  Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink to
  Magento\Framework\App\View\Asset\MaterializationStrategy\Copy

inside my deafult di.xml file as default there's:

    <virtualType name="developerMaterialization" type="Magento\Framework\App\View\Asset\MaterializationStrategy\Factory">
    <arguments>
        <argument name="strategiesList" xsi:type="array">
            <item name="view_preprocessed" xsi:type="object">Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink</item>
            <item name="default" xsi:type="object">Magento\Framework\App\View\Asset\MaterializationStrategy\Copy</item>
        </argument>
    </arguments>
</virtualType>

I tried to delete the first symlink part or change it into "copy" but it's not working.


texts: There is no cron_email_queue & cron_email_queue_recipients tables in my database. Not sending order confirmation emails, in magento 2

texts:
My cron jobs are working per 1 minute. But order confirmation emails are not sending.

When I checked in my db, cron_email_queue & cron_email_queue_recipients tables are missing.

What to do? I'm using Magento 2.

  Note: Account creation emails are reaching the user.


texts: How can I get list of all product/category fields in Magento 2?

texts:
I need to display all fields (column names) from product/category.
How can i do that?

Get instance and then foreach as key => value is a bad idea.


texts:
I constructed a widget where you can input product sku's and then get a small preview.

Since more and more Elements are required, I was thinking of using the /app/design/frontend/base/default/template/catalog/product/list.phtmlto show within the widget. That would be much easier then calling attribute by attribute again an designing everything allover.

So I have built an array like this:

$_products = array($product_1,$product_2,$product_3,$product_4);
$_products =Mage::getModel('catalog/product')->getCollection()
->addAttributeToFilter('sku', array('in' => $_products))
->addAttributeToFilter('status', 1)
->addAttributeToSelect('*')
->addUrlRewrite();

Now I want to output this within a list.phtml file. Everything described so far happens in the widgets phtml file.

Is there a way to use list.phtml now?
I tried with:

   <?php echo $_product->getChildHtml('prices'); ?>

Bu I guess I am still missing this block within the widget.

How do I load list.phtml into a new block which is working within the widgets?

EDIT: I tried this too

<?php echo $_product->getPriceHtml(); ?>

But it doesn't work.


texts: Magento 2 contact us page tracking pixel

texts:
I want to track the leads from my contact us page.

I want to use google adwords tracking code for that job.

I know that under Stores->Configuration->Sales->Google API I can set the Google Adwords, but it's only for the checkout success page.

So how can I track the leads from the contact us form also?

Thanks


texts: How to use resultJsonFactory in Model file magento2

texts:
I have used below code to print response from my Model file.

<?php

class CountrylistManagement implements
   \Vendor\Module\Api\CountrylistManagementInterface
{
protected $_storeManager;
protected $objectManager;
protected $_resource;
protected $resultJsonFactory;
public function __construct(
    \Magento\Framework\App\Action\Context $context,
    \Magento\Framework\ObjectManagerInterface $objectManager,
    \Magento\Store\Model\StoreManagerInterface $storeManager,
    \Magento\Framework\App\ResourceConnection $resource,
    \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
) {
    $this->_objectManager = $objectManager;
    $this->_storeManager = $storeManager;
    $this->_resource = $resource;
    $this->resultJsonFactory = $resultJsonFactory;
    parent::__construct($context);
}
     public function postCountrylist($params)
{
    $resultArr = array();
    $request =  json_encode($params);
    $resultArr['message'] = "Success";
    $resultArr['code'] = 200;
    $resultJson = $this->resultJsonFactory->create();
    $resultJson->setData($resultArr);
    return $resultJson;
  }
}

Here I am trying to print the json response from the model file,
The above code works well from controller.

Can we use $resultJson = $this->resultJsonFactory->create(); to print the response from model file?

right now its not working for me. if anyone can look into this and update where i am doing wrong please.


texts:
I m trying to include bootstrap js on my magento2 theme. But the problem is when i include bootstrap js on my theme. That time console is giving error that bootstrap require jQuery.

Then how can i do it???
Can anyone please help me?


texts:
I am creating a page that display in stock products.
I am using

Mage::getSingleton('cataloginventory/stock')->addInStockFilterToCollection($this->_productCollection);

in my custom product list block extending Mage_Catalog_Block_Product_List.
But this code includes products that have qty=0. If i added filter qty>0, it will also remove configurable product that have qty=0 BUT have simple(child,associated) products with qty > 0.
How do I solve this?

Basically, from this current list, i want to filter out simple product that have qty < 1.


texts: Error 404 : The server can not find the requested page: /customer/account/login (port 443)

texts:
I'm getting this error when I try to access one page checkout and my account page on my website. I'm using Magento 1.9. All pages, except those two are working fine.

What issue can cause this, and how can I resolve it?


texts:
http://www.magentocommerce.com/magento-connect/aramex-shipping-and-tracking-extension.html

Someone got experience in using Aramex Shipping and Tracking Extension?

Got customter with need for that but I am unsure if it will really work bacause:

Official support for 1.7, we got 1.7.0.2
Only one review so far and it isnt a good one

May someone can confirm a working installation on 1.7.0.2?


texts: How to get the deployment version in Magento 2?

texts: I want to save deployment version in DB from where I can get the currently deployed version?


texts: What is the purpose of isAllowed method and when It is called in Magento 2?

texts:
I have seen that below method.

protected function _isAllowed()
{
    return $this->_authorization->isAllowed('Custom_Module::moduleslider_banners');
}

What exactly it will do?
Will it check the user is logged in or not?
When it's called?

Why i'm asking because in my custom Module i'm using this, but when session expire on Admin side & if i'm on my Custom Module Page then it gives below error

Magento 2: Fatal error: Uncaught Error: Call to a member function getId()

When session expire it should automatically redirect to Login page of Admin, but it's not working like that.


texts: Programmaticaly use catalog permission based on user group

texts:
Is there a way to restrict catalog / product page based on user group (for example, if my user is in the group "A", he will see only product for the group "A") ?

Ideally by avoiding paid extension if anyone know reply me.


texts:
Magento 1.9
We want to Create a group of different coupon codes , and there is chance that multiple coupon code can be received by single customer. Here system must restrict to use only one coupon code in that group. If customer uses coupon from another group then it can allow. Is there any possible way to achieve this?


texts: Magento 2 : Change image sizes in fotorama

texts:
How do I change the images sizes of the fotorama gallery ?

From what I understand I need to edit my view.xml

But what Image Id's do I need to change please.

Also do I need to run some mage command after to see the changes ?

Thanks.


texts: Combine attribute to use for ebay products in m2e pro

texts:
i am using magento 1.9.0.1 and i am listing items on ebay using magento extension called m2e pro.

as a description to show in ebay i am using attribute "description" but with that the problem is, it only list value of long description.

i want to list long description and specification as well. for that i need to make an attribute which has both of these values, but only for use in m2e pro not to display on front end of website etc.

can any one help me to achieve this please?

Thanks you in advance.


texts: how to optimize queries in magento 1.9 with lots of attributes (over 500)

texts:
I have a website running Magento 1.9 which is flooding mysql with slow queries like this
SELECT COUNT(DISTINCT e.entity_id) FROM `catalog_product_entity` AS `e`
 INNER JOIN `catalog_product_index_price` AS `price_index` ON price_index.entity_id = e.entity_id AND price_index.website_id = '1' AND price_index.customer_group_id = 0
 INNER JOIN `catalog_category_product_index` AS `cat_index` ON cat_index.product_id=e.entity_id AND cat_index.store_id='1' AND cat_index.visibility IN(3, 4) AND cat_index.category_id = '2' WHERE (`e`.`entity_id` IN(78661, 78664, 78668, 78659, 78660, 78658, 78657, 78656, ...about 1000 more ids)

I'm assuming this has to do with caregory and layered navigation so I disabled the layered navigation counts globally. It helped mitigate the problem but it's still not quite solved so I want to takle it at the source.
Could someone help me understand when these queries are run and why this is happening?
Another example
SELECT `trofodosia_boyrtsas_idx`.`value`, COUNT(trofodosia_boyrtsas_idx.entity_id) AS `count` FROM `catalog_product_entity` AS `e`
 INNER JOIN `catalog_product_index_price` AS `price_index` ON price_index.entity_id = e.entity_id AND price_index.website_id = '1' AND price_index.customer_group_id = 0
 INNER JOIN `catalog_category_product_index` AS `cat_index` ON cat_index.product_id=e.entity_id AND cat_index.store_id='1' AND cat_index.visibility IN(3, 4) AND cat_index.category_id = '2'
 INNER JOIN `catalog_product_index_eav` AS `trofodosia_boyrtsas_idx` ON trofodosia_boyrtsas_idx.entity_id = e.entity_id AND trofodosia_boyrtsas_idx.attribute_id = '321' AND trofodosia_boyrtsas_idx.store_id = '1' WHERE (`e`.`entity_id` IN(78661, 78664, ...more ids)
GROUP BY `trofodosia_boyrtsas_idx`

They seem to be fairly common in all magento 1.9 running instances and connected to the layered navigation and pagination.
Is there something I could change on mysql server to improve this?
Is this behaviour something documented in Magento 1.9?
PS: Due to the amount of attributes I can't enable flat catalog because it hits the max row limit in mysql.


texts:
I want to load the top menu with ajax , so far i have created another php file that will serve the menu on the header by trying to customise it to magento following this tutorial:
http://phppot.com/demo/load-dynamic-content-using-jquery-ajax/

<?php

require_once '../app/Mage.php';

Mage::app('default');
umask(0);

$_helper = Mage::helper('catalog/category');
$categories = $_helper->getStoreCategories();

?>

<?php
if(!empty($categories)) {
?>

<?php
foreach($categories as $category) { ?>

<input type="button" value="<?php echo $category["name"]; ?>" onMouseover="getChildrenCategories(<?php echo $category["id"]; ?>);" /><?php }?>

<?php } ?>

but i do not know exactly how to connect the get_subcats.php ajax file , to understand which parent categorie's should display the childrens.
So far i have this but i am sure it is wrong, it will not display anything.

<?php

require_once '../app/Mage.php';

Mage::app('default');
umask(0);

$_helper = Mage::helper('catalog/category');
$categories = $_helper->getStoreCategories();
if (count($categories) > 0){
    foreach($categories as $category){
        $category = Mage::getModel('catalog/category')->load($category->getId());
        $subcategories = $category->getChildrenCategories();
        if (count($subcategories) > 0){
           //  echo $category->getName();
//             echo $category->getId();
            foreach($subcategories as $subcategory){
               //   echo $subcategory->getName();
//                  echo $subcategory->getId();
            }
        }
    }
}

if(!empty($category)) {

?>

<?php echo $subcategory[0]['id'];?>

<?php echo $subcategory[0]['name'];?>

<?php } ?>


texts: Removing item from cart on Observer method

texts:
This is triggered on the checkout_cart_add_product_complete event.

Firstly the code in the if($itemCount > 1) statement works absolutely fine and as expected (it removes the last item/item just added to cart). However the code in the else statement does not.

The item is a simple product.

The else statement is triggered when the customer has an empty cart, and is adding a first product to it which happens to be an item that has failed a check. So it needs to be removed from the cart, leaving them with an empty cart (and some error messages eventually).

However, the else statement does not want to delete that first and only item from the cart. You will be able to see all of the other methods I have tried as I have just commented them out.

I use XDebug and have been stepping through the code, so I can assure you that it makes it into the statement and executes $cart->removeItem($itemId)->save(); - However no errors are shown in logs or from the catch.

I'm at a loss with this, tried so many things but all to no avail. Please someone shed some light & make what I want to achieve possible! Thanks.

Code:

    public function removeItem(Varien_Event_Observer $observer)
{
    $event = $observer->getEvent();
    $productId = $_SESSION['prescription']['product_id'];
    $result = $_SESSION['prescription']['result'];

    if($result == 0)
    {
        $cart = Mage::helper('checkout/cart')->getCart();
        $items = $cart->getItems();
        $itemCount = count($items);
        if($itemCount > 1)
        {
            $i = 0;
            foreach($items as $item)
            {
                $i++;
                if($i == $itemCount)
                {
                    if($item->getProduct()->getId() == $productId)
                    {
                        $itemId = $item->getItemId();
                        $cart->removeItem($itemId)->save();
                    }
                }
            }
        }
        else
        {
            foreach($items as $item)
            {
                if($item->getProduct()->getId() == $productId)
                {
                    try{
                        $itemId = $item->getItemId();
                        $cart->removeItem($itemId)->save();
                        //Mage::getSingleton('checkout/cart')->truncate()->save();
                        //$quote = Mage::getSingleton('checkout/session')->getQuote();
                        //$quote->removeItem($itemId)->save();
                    }catch (Exception $e)
                    {
                        Mage::log('Failed to remove item from cart'.$e.'.');
                    }
                }
            }
        }
    }
}


texts: Magento2.3 - How to Sort Products Based on Attribute Category

texts:
Is it possible to add an order by category attribute in the search catalog?

I would like to add search relevance based on category positions.
For example if I search Iphone the result returns to me: iphone case (whose category accessory) and then apple iphone (whose category gsm).

However I would like the result to display the products with the category gsm and then the category accessory, the result would be: apple iphone 7, apple iphone 8 and then iphone 7 case etc.


texts: How to disable layered navigation on certain categories

texts:
I want to disable the layered navigation on some certain categories, can someone help me?

case 1:

  disable it through category id, for example on category id 4

case 2:

  only disable it on parent categories. For example, if category A has
  subcategories, disable it on category A. But it will be shown at
  category A's subcategories


texts: Magento 2: 'Tax Class' is not showing in products from admin panel

texts:
After migrating data from Magento 1 to Magento 2, i can not see 'Tax Class' attribute from admin panel while editing a product. 'Stock Status' attribute is also missing. But when i create new product, then these attributes can be seen. The problem with migrated products only.

Any solution?


texts: how to schedule reindex of catalog_category_product only

texts:
I need to run separately with its own schedule the reindexing of:

  catalog_category_product
  catalog_product_category
  catalog_category_flat

I dont find the in any crontab.xml

How can we do this?
Thanks


texts: Magento completely broken: Call to a member function getCode() on boolean & There was no 404 CMS page configured or found

texts:
Suddenly (without any changes or updates) our magento installation seems to be completely broken.

Every day we're now getting some of this errors:

There was no 404 CMS page configured or found when accessing /index.
The magento installer suddenly shows up when accessing /index
No template is showing up (as shown in the picture)

Strange redirects. When everything seems to work (no 404 cms error, no template issues) and I try to visit a product I sometimes get redirected to the home page.

Well, what I did so far is:

flushed cache folder, flushed session folder
truncated table core_url_rewrite

It seemed to work. After reindexing (core_url_rewrite) everything seemed broken again so I truncated again. With empty core_url_rewrite it looked all okay. But the next day it was broken again.

Well and today it's the same again but today it's also the first time where flushing cache, sessions and core_url_rewrite doesn't work anymore.

Oh and this is showing up in our nginx error log:

  [error] 11773#11773: *242799 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Call to a member function getCode() on boolean in /htdocs/seg_posorder/stage/app/code/core/Mage/Customer/Model/Session.php on line 71" while reading response header from upstream, client: 217.24.X.X, server: www.example.com, request: "GET /index.php/customer/account/login/ HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "www.example.com", referrer: "example.com"

But our stores also seem okay:


texts:
I need to send order email in this  shipping_arrival_time how to send this

observer.php

class Bc_Deliverydate_Model_Observer
    {

        public function checkout_controller_onepage_save_shipping_method($observer)
        {
            if (Mage::getStoreConfig('deliverydate/deliverydate_general/on_which_page')==1){
                $request = $observer->getEvent()->getRequest();
     //           $quote =  $observer->getEvent()->getQuote();

        $quotes = Mage::getModel('sales/quote')->getCollection();

                $desiredArrivalDate = Mage::helper('deliverydate')->getFormatedDeliveryDateToSave($request->getPost('shipping_arrival_date', ''));
                if (isset($desiredArrivalDate) && !empty($desiredArrivalDate)){
                    $quotes->setShippingArrivalDate($desiredArrivalDate);
                    $quotes->setShippingArrivalComments($request->getPost('shipping_arrival_comments'));
                    $quotes->setShippingArrivalTime($request->getPost('shipping_arrival_time'));
                    $quotes->save();
                }
            }

            return $this;
        }

}


texts:
Is it possible to disable the merging of same products into one position in the cart?

So when someone adds Product ABC with Qty 1 to the cart, continues shopping and adds the same product again with Qty 2, Magento merges/sums the two products into one position with a Qty of 3.

I’d like to have 2 cart positions with Product ABC with their respective quantities. Is that possible?

The only thing I was finding while looking through the code was Mage_Sales_Model_Quote::merge, but that doesn't seem to be the right method as it handles merging the carts from a former session after logging in.

Thanks a lot!


texts: adding bundle product with default options with setLocationAjax function

texts:
I'm trying to add to cart a bundle product with default options (options already selected from backend) using the setLocationAjax function. I managed to get the correct url to add which will be javascript:setLocationAjax('http://example.com/checkout/cart/add/uenc/aHR0cDovL2lsYWVtcy5jb20vc2FuZHdpY2hlcy5odG1s/product/29/form_key/YMC8gewJKkZd3QK6/?&bundle_option[2]=4&bundle_option_qty[2]=1.0000&bundle_option[3]=6&bundle_option_qty[3]=10.0000&bundle_option[4]=13&bundle_option_qty[4]=5.0000')

for some reason I'm getting the message "Please specify product option(s)." while if I'm not using ajax it will work fine.

any ideas what is missing here.

Thanks


texts: Admin order grid: Column 'store_name' in where clause is ambiguous when filtering by store

texts:
I am getting this error when trying to filter the sales grid by store. I can fix this error by altering app\code\core\Mage\Adminhtml\Block\Sales\Order\Grid.phpand replacing

if (!Mage::app()->isSingleStoreMode()) {
    $this->addColumn('store_id', array(
        'header'    => Mage::helper('sales')->__('Purchased From (Store)'),
        'index'     => 'store_id',
        'type'      => 'store',
        'store_view'=> true,
        'display_deleted' => true,
    )); }

with

if (!Mage::app()->isSingleStoreMode()) {
    $this->addColumn('store_id', array(
        'header'    => Mage::helper('sales')->__('Purchased From (Store)'),
        'index'     => 'main_table.store_id',
        'type'      => 'store',
        'store_view'=> true,
        'display_deleted' => true,
    ));
}

However, I would like to understand why this is happening in the first place.
Also if I edit Grid.php like that, all my store view names will include [deleted] - this I don't understand at all...


texts: When no price is required how to stop it displaying 0.00

texts:
Yesterday with some help from here I managed to work out configurable attributes so I could put a wine into my wine store and have the different year options for that wine with different prices depending on the year.

I then turned the price requirement off so when i load the first product I didn't have to have a price on it it would be like teh master product with teh drop down menu for the years available in that master product. http://www.cellar2door.com/index.php/reds/chile/montes-folly-syrah-38.html

Problem is that even though there is no price for teh master product it still displays as Rp0,000.

Is there a way to set the code so that if a price is not entered then nothing is displayed it is just blank?

Many thanks,


texts: Cannot create a package for FedEx shipment process. Please guide with the proper flow on how to create a package.


texts: How to add currency suffix to URL links?

texts:
I need to add a currency suffix to url links for the products.
For example: When switching currency to CAD or USD in ANY Magento store. There is NO code in the URL links which states the currency.

www.example.com/pencils.html

I need is this: When switching currency to USD
link should look like:

www.example.com/pencils.html?currency=usd

When switching currency to CAD
link should look like:

www.example.com/pencils.html?currency=cad


texts: how to call checkout onepage failure with personal error message?

texts: I am making a payment gateway module, When ever the payment fails I want to display the error message I got in the response parameters, when I redirect to checkout/Onepage/failure.


texts: Google URL Tags Showing in Global Messages

texts:
A strange error I noticed on my Magento 2.2 site yesterday, When I create a URL with google tag generator and then click the link through to the page the campaign tags appear in what I believe is the global messages area of the product pages. under cookie messages.

I can't just remove the globabl message area as there are other messages like added to cart or quote success message appearing which I require.

How can  I stop the cookies messages from appearing in the global message area with out effecting the other success / fail messages ?

E.g.
If i create the link :

  https://burtonsveterinary.com/vetair-mobile-dental-unit-offer.html?utm_source=Website&utm_medium=Banner&utm_campaign=Sale&utm_content=dentalPromo

and then go on the front end page, it displays :

  "utm_source=Website&utm_medium=Banner&utm_campaign=Sale&utm_content=dentalPromo"

above the page image.

Any help would be great

Thanks


texts: Show tracking link for custom shipping method

texts:
We defined a custom shipping method by extending Mage_Shipping_Model_Carrier_Abstract.

There is a method

public function isTrackingAvailable()
{
    return true;
}

But after we enter a tracking number for an order, the tracking popup is empty.

Which method has to be implemented to display tracking links in the popup?


texts: Anybody know the Reference block name for the Footer->Miscellaneous HTML

texts:
Within Content->Design->Configuration->Theme->Footer->Miscellaneous HTML I have added some HTML and it works correctly
However, I use a popup and it also displays at the bottom of the popup window
Through the pop-ups Layout.xml I would like to remove the Miscellaneous HTML using something like
<referenceBlock name="XXXXXXXXXX" remove="true"/>

Can anyone please give me the referenceBlock name for the Miscellaneous HTML?


texts: How to show custom validation message in checkout?

texts:
I have created some coupons. when a coupon applied it dispatch an event salesrule_validator_process.

In the observer I will check some condition. based on condition the coupon will apply to the cart. But here how can I show a custom validation message if coupon not allowed?

  Observer

public function execute(EventObserver $observer)
{
    //return $this;
    $rule           =   $observer->getEvent()->getRule()->getData();
    $couponCode    =   $rule['coupon_code'];
    $customerId     =   $this->_customerSession->getCustomer()->getData('entity_id');

    $userId     =   '';
    $validity   =   -1;

    $userId    =   $this->_rule->customerIdToUserId($customerId);
    $validity  =   $this->_rule->checkPromoRule($userId,$couponCode);

    if ($validity == 0) {
        $this->_logger->debug("Coupon Not Valid");
        $this->_logger->critical("Couponcode Not Allowed");
        $this->_qoute->getQuote()->setCouponCode(NULL)->save();
        return $this;
    }

    return $this;
}


texts: Database connection error, after CLI install?

texts:
First time Magento user here, seeking enlightenment. I did a CLI install on CentOS 7 using the following command...
./bin/magento setup:install
 --base-url="http://example.com/shop/"
 --db-host="127.0.0.1" --db-name="th_magento"
 --db-user="th_magento" --db-password="asdfashd238"
 --admin-firstname="Hugh" --admin-lastname="Mongous"
 --admin-email="humongous@example.com" --admin-user="admin"
 --admin-password="b39fe8a09" --backend-frontname="aaa"

[... ssh buffer too small ...]

Module 'Magento_WebapiAsync':
[Progress: 818 / 833]
Module 'Magento_WebapiSecurity':
[Progress: 819 / 833]
Module 'Magento_Weee':
[Progress: 820 / 833]
Module 'Magento_WeeeGraphQl':
[Progress: 821 / 833]
Module 'Magento_CatalogWidget':
[Progress: 822 / 833]
Module 'Dotdigitalgroup_Email':
[Progress: 823 / 833]
Module 'Magento_WishlistAnalytics':
[Progress: 824 / 833]
Module 'Magento_WishlistGraphQl':
[Progress: 825 / 833]
Module 'Temando_Shipping':
[Progress: 826 / 833]
Module 'Vertex_Tax':
[Progress: 827 / 833]
[Progress: 828 / 833]
Installing admin user...
[Progress: 829 / 833]
Caches clearing:
Cache cleared successfully
[Progress: 830 / 833]
Disabling Maintenance Mode:
[Progress: 831 / 833]
Post installation file permissions check...
For security, remove write permissions from these directories: '/home/example/public_html/shop/app/etc'
[Progress: 832 / 833]
Write installation date...
[Progress: 833 / 833]
[SUCCESS]: Magento installation complete.
[SUCCESS]: Magento Admin URI: /aaa
Nothing to import.

For some reason I can't understand1 all I get when I navigate to /aaa is an Error while establishing database connection message (rough translation, locale is not english).
I tried some basic troubleshooting like checking requirements with the web based install, and ensuring that I can login using the MySQL client and it works. I can't find the logs for the error, tough...
I can post additional data if needed. It might be worth noting the SQL server is  MariaDB 10.0 and that the frontend shows no errors (it seems to display correctly).

1: Wouldn't the install stop before the [SUCCESS]: Magento installation complete. if there was a problem?

Update: env.php
The db user and password match...
'db' => [
        'table_prefix' => '',
        'connection' => [
            'default' => [
                'host' => 'localhost',
                'dbname' => 'th_magento',
                'username' => 'th_magento',
                'password' => 'asdfashd238',
                'model' => 'mysql4',
                'engine' => 'innodb',
                'initStatements' => 'SET NAMES utf8;',
                'active' => '1'
            ]
        ]
    ],

While at it I also enabled developer mode, but nothing changed in the error page html. The var/log/debug.log file contains only  cache_invalidate entries, while connector.log is empty.


texts: How to configure Multi Source Inventory (MSI) in Magento 2.3

texts:
I've heard that Magento Core guys have just developed Multi-Source Inventory functionality

(https://github.com/magento-engcom/msi).

So I guess it means that I can place my products in different countries and depots to be calculated by Magento.

I want to use this feature on my website, because I've been trying to do something like this for a long time.

So, does anybody know how to correctly configure this feature?
Also Share any helpful links or manuals ?

Thanks in advance!


texts:
My site is facing customer login error. I receive below message:

  Invalid Login Detail The login attempt was unsuccessful. Some
  parameter is missing Or wrong data

Please help me.


texts: Use search_criteria to filter custom extension collection in Magento 2

texts:
I generated a custom extension with a custom model collection from mage2gen , is it possible to implement the search_criteria like when you retrieve product using rest api? what i know is the product model will use getList function to filter collection by search_criteria:

$this->procudtRepository->getList($searchCriteria);

if i have a post input with parameter search_criteria like this:

'searchCriteria' => [
  'page_size'=> 3,
  'current_page'=> 15,
  'filterGroups' => [
    0 => [
      'filters' => [
         0 => [
           'field' => 'location',
           'value' => '%as%',
           'condition_type' => 'like'
         ]
    1 => [
      'filters' => [
         0 => [
           'field' => 'distance',
           'value' => '100',
           'condition_type' => 'lt'
         ]
      ]
    ]
  ]

Is it possible to just implemented it like this:

public function __construct(
 /Namespace/Module/Model/CollectionFactory $collection
){
 $this->collection = $collection;
}

public function execute(){
 $searchCriteria = $this->getRequest()->getPostValue('searchCriteria');
 $collections = $this->collection->create()->getList($searchCriteria);
 return $collections;
}


texts: Magento2 not executing InstallSchema.php or UpgradeSchema.php

texts:
I've created a custom module, and I see the row in the setup_module table. When I change my version and run magento setup:upgrade, the version number updates as well. However, the table I defined is not being created. I also see the new module enabled in app/etc/config.php

I tried installing a module written by Magento, but I still see the same behavior - row is in setup_module but table does not exist.

I tried deleting the row from setup_module table and rerun magento setup:upgrade to execute InstallSchema.php, but the database tables aren't created even though the row is created setup_module again.

I also tried incrementing the version number and try UpgradeSchema.php, but it doesn't execute even though row in setup_module is updated.

I introduced errors in both InstallSchema.php and UpgradeSchema.php, but magento setup:upgrade doesn't does not output the error messages.

I also tried recreating the installation, and ensuring the file permissions were correct (owned by magento:www-data). Any other ideas?

I'm using v2.0.7 CE provided by DigitalOcean.

<?php
namespace Test\Project\Setup;

use Magento\Framework\Setup\InstallSchemaInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\SchemaSetupInterface;
use Magento\Framework\DB\Ddl\Table;

class InstallSchema implements InstallSchemaInterface
{
    public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
    {
        $installer = $setup;
        $installer->startSetup();

        // Get tables
        $tableName = $installer->getTable('test_module');

        // Create table
        $table = $installer->getConnection()
        ->newTable($tableName)
        ->addColumn(
            'id',
            Table::TYPE_INTEGER,
            null,
            [
            'identity' => true,
            'unsigned' => true,
            'nullable' => false,
            'primary' => true
            ],
            'ID'
        )
        ->addColumn(
            'title',
            Table::TYPE_TEXT,
            null,
            ['nullable' => false, 'default' => ''],
            'Title'
        )
        ->setOption('type', 'InnoDB')
        ->setOption('charset', 'utf8');

        $installer->getConnection()->createTable($table);
        $installer->endSetup();
    } // close function install()
}


texts: Magento2 change response before full page cache

texts:
I know my question is strange and I should change the response in the Magento way.

I have an observer subscribed to controller_front_send_response_before event.

events.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <event name="controller_front_send_response_before">
        <observer name="roland_controller_front_send_response_before"
                  instance="Roland\HelloWorld\Model\Observers\ResponseBefore"/>
    </event>
</config>

Model/Observers/ResponseBefore.php

<?php
namespace Roland\HelloWorld\Model\Observers;

use \Magento\Framework\Event\ObserverInterface;

class ResponseBefore implements ObserverInterface {

    public function execute(\Magento\Framework\Event\Observer $observer) {

        $this->playWithResponse($observer->getEvent()
                                   ->getData('response'));

    }

    public function playWithResponse($response) {

        $head = '<script>alert("'.time().'");</script>';
        $response->setBody(preg_replace('/<\/head>/', $head . '</head>', $response->getBody(), 1));
    }

}

It works fine when Full page cache not enabled. Every time I refresh the page, I get an alert with the current server time. When Full page cache is enabled, I would like to make my code cached into Full page cache. Currently my observer called on every page load as the Full page cache comes before the controller_front_send_response_before event.

So I checked how's Magento 2 Full page cache works in magento/module-page-cache/Observer/Process/LayoutRenderElement.php

    public function execute(\Magento\Framework\Event\Observer $observer)
{
    $event = $observer->getEvent();
    /** @var \Magento\Framework\View\Layout $layout */
    $layout = $event->getLayout();
    if ($this->isFullPageCacheEnabled() && $layout->isCacheable()) {
        $name = $event->getElementName();
        /** @var \Magento\Framework\View\Element\AbstractBlock $block */
        $block = $layout->getBlock($name);
        $transport = $event->getTransport();
        if ($block instanceof \Magento\Framework\View\Element\AbstractBlock) {
            $blockTtl = $block->getTtl();
            $output = $transport->getData('output');
            if (isset($blockTtl) && $this->isVarnishEnabled()) {
                $output = $this->_wrapEsi($block, $layout);
            } elseif ($block->isScopePrivate()) {
                $output = sprintf(
                    '<!-- BLOCK %1$s -->%2$s<!-- /BLOCK %1$s -->',
                    $block->getNameInLayout(),
                    $output
                );
            }
            $transport->setData('output', $output);
        }
    }
}

I saw that it caches every block, but I haven't got any further.

Here is the part of my $event->getElementName():
mailcheck_init
emailCapture
copyright
before.body.end
page.wrapper
root

I thought if I change the content in the observer before the page cache that might worth, but I have no luck.

if($event->getElementName() == 'root'){
    $transport = $event->getTransport();
    $transport->setData('output', 'test');
}

Do you have any suggestion how should I achieve the desired result?


texts: how to change the status of the order to pending from complete?

texts: By mistake one of our order was marked as completed which not really completed. How shall we make the completed order again as pending?


texts: Magento 2. Product not visible in any category or product listing

texts:
None of my products are visible in any product listing,category view,search.

I've checked all the usual suspects.

Products are enabled, stock is not managed, they are assigned to website etc.
Indexers have run successfully. checked the tables myself.
Ran setup:upgrade, static:content, code generation
Permissions on media, generated, var,pub, app,etc are 777. Ownership is magento:www-data.
Crons ran successfully.
Nothing in magento logs.
Nothing in apache logs.
Nothing in browser console.
htaccess files are present.

I can see the products by individual url, only product listings are affected.

It is worth to note that I have a custom admin url. And all requests to backend are handled by a server and all requests to frontend are handled by another server.

I'm using Redis for cache and memcached for session storage.

With the same code I can't reproduce this on my local machine.

I had a similar issue at a previous deploy and fixed it with full permissions on media folder.

I suspect this is caused either by the separation of the nodes (admin -> one server, web -> another server) either by some server configuration.

Any hints, pointers to debugging this?


texts: Change staus of downloadable product in magento after purchase?

texts:
All products in my site are downloadable,
 I have uploaded the respective files while creating product.

But after purchase when user is redirected to his downloadable products, the link does not work and the status is pending.

The links only work if the status is set to complete via admin.

But I don't want this , user should be able to download the product after purchase,
Is their any way to set the default status of downloadable product to complete?


texts: How to stop process or flow of a event observer

texts:
Please someone tell me how to stop process(flow) of any event observer.

i.e an event observer if - "before_create_account"

i know this i can use this event and do something before a new account create. But what i have to do if i want to stop actual process of this event. i want to stop flow. If some condition is false then user will not able to create account. i want to check some condition before account create and if that condition is false new account registration should be rejected. what code i have to write for this.

before_create_account is just an example i know its not true event


texts: Magento 2.3.4 custom module - Uncaught Error: Call to a member function setData() on boolean

texts:
I've got a custom Magento 2 module that is causing issues on newly created products. All of the existing ones seem to be okay. I'm running Magento 2.3.4

in my template: /app/design/frontend/MySite/MyTheme/Magento_Catalog/templates/product/view/attributes.phtml

<?php
    $_helper = $this->helper('Magento\Catalog\Helper\Output');
    $_product = $block->getProduct()
?>

$block->getChildBlock("myblock")->setData("my_data", $_product);
echo $block->getChildHtml('myblock', false);

The line that reads  $block->getChildBlock("MyBlock")->setData("my_data", $_product);  is throwing the following error:

  PHP Fatal error:  Uncaught Error: Call to a member function setData() on boolean in /var/www/mysite.com/app/design/frontend/MySite/MyTheme/Magento_Catalog/templates/product/view/attributes.phtml

Any idea why this would work for all products but newly added ones? The contents of the block being referenced are irrelevant at this point as it's not making it far enough to load it.

Edited to add XML (catalog_product_view.xml):

<?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.attributes" destination="product.info.price" after="-"/>
        <referenceBlock name="product.attributes">
            <block class="Catalog\MyBlock\Block\Catalog\Product\Myblock" name="catalogmyblock" as="myblock" template="Catalog_MyBlock::view/myblock.phtml">
            </block>
        </referenceBlock>
        <!-- <referenceContainer name="product.info.price" remove="true"/> -->
        <referenceContainer name="product.info.addtocart" remove="true"/>

    </body>
</page>


texts: Magento 2 REST API: Create an API to fetch recently viewed products

texts:
I need to create an API for fetching all the recently viewed products.

Any suggestions on how to do it?


texts:
I am looking to achieve a brands listing page, listing brands (held as categories) alphabetically with a sub-group for each letter. For example, Adidas, Asics etc. would all appear under 'A', Barbour, Banks under 'B' and so on.

Here's my current code that does a great job of listing all the brand categories - however I am stuck trying to get them listed under the associated letter of the alphabet.

<?php
$parentCategoryId = 5;
$category = Mage::getModel('catalog/category')->load($parentCategoryId );
$children = Mage::getModel('catalog/category')->getCollection()->setStoreId(Mage::app()->getStore()->getId());
$children->addAttributeToSelect('*')->addAttributeToFilter('parent_id', $category->getId())
    ->addAttributeToFilter('is_active', 1)//get only active categories if you want
    ->addAttributeToSort('name');//sort by position
 $mode = $this->getRequest()->getParam('mode');
?>

    <?php foreach ($children as $child) {
        $skin_url = $child->getImageUrl(); ?>
        <li <?php if ($mode=='1'){echo 'style="width:100%"';}?>>
            <a href="<?php echo $child->getURL();?>" title="<?php echo $child->getName();?>">
                <?php echo $child->getName();?>

    <?php   }?>


texts: Programmatically create product with different attributes in store views

texts:
I have problem ,while i programmatically create product. I want add two different values for store views

$product = Mage::getModel('catalog/product');
$product->setStoreId(1)->setData('name', 'English name')->save();
$product->setStoreId(2)->setData('name', 'Polish name')->save();

After those operation I have proper data in catalog_product_entity_varchar

┌────────┬──────────────┬────────────┬────────┬─────────┬────────────┐
│value_id│entity_type_id│attribute_id│store_id│entity_id│value       │
├────────┼──────────────┼────────────┼────────┼─────────┼────────────┤
│1       │10            │96          │0       │1        │English name│
├────────┼──────────────┼────────────┼────────┼─────────┼────────────┤
│6       │10            │96          │2       │1        │Polish name │
└────────┴──────────────┴────────────┴────────┴─────────┴────────────┘

And this data are good.....

BUT if I want add description (the same way) after name

$product->setStoreId(1)->setData('description', 'English')->save();
$product->setStoreId(2)->setData('description', 'Polish')->save();

catalog_product_entity_varchar change to:

┌────────┬──────────────┬────────────┬────────┬─────────┬────────────┐
│value_id│entity_type_id│attribute_id│store_id│entity_id│value       │
├────────┼──────────────┼────────────┼────────┼─────────┼────────────┤
│1       │10            │96          │0       │1        │English name│
├────────┼──────────────┼────────────┼────────┼─────────┼────────────┤
│2       │10            │96          │1       │1        │Polish name │
├────────┼──────────────┼────────────┼────────┼─────────┼────────────┤
│6       │10            │96          │2       │1        │Polish name │
└────────┴──────────────┴────────────┴────────┴─────────┴────────────┘

What is that? I must make additional operations between those setData? If I comment description part everything works well :(


texts: magento 2 api route with input parameter

texts:
I'm trying to create an api route with input parameters but I'm not getting the expected result.

Here is my webapi.xml:

<?xml version="1.0"?>
<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../app/code/Magento/Webapi/etc/webapi.xsd">
    <route url="/V1/foo" method="POST" secure="true">
        <service class="..\FooInterface"
                 method="getFooById"/>
        <resources>
            <resource ref="anonymous"/>
        </resources>
        <data>
            <parameter name="id" force="true">%id%</parameter>
        </data>
    </route>
</routes>

Here my interface:

interface FooInterface
{
    /**
     * Test function
     *
     * @api
     * @param string $id
     * @return string
     */
    public function getFooById($id);
}

And here the class:

class Foo implements FooInterface
{
    /**
     * {@inheritdoc}
     */
    public function getFooById($id){
        return $id;
    }
}

I'm omitting the di.xml with the preference.
Now if I call that route whatever I do all I get back is %id%. Even if I don't put any parameter I get that instead of an error or something.

What am I doing wrong here?

Here is the call in postman:

I tried:

sending a get request
sending a get request with parameter /order?id=foo
sending a post request
sending a post request with form-data
sending a post request with raw data (as seen in screenshot)

All have the same result -> %id%

I'm using community edition btw.


texts:
I have 2 store views. The default view loads fine and seems to be fully operating. The added store view is failing. It also doesn't load directly by URL, it re-directs to default. My setup is 1 website > 2 Stores > 2 store views.
I am accessing the added store view with the store switcher at the bottom of the page.

I am getting this error in development mode:

Magento\Framework\Exception\NoSuchEntityException: No such entity. in /home/cityprin/public_html/citysearchlocal.com/get-found-on/vendor/magento/module-store/Model/WebsiteRepository.php:80


texts:
Any extension or module for paytrace magento 1.
I have one that I found on git but that have issue with invoice when capture online.
Else if have the paytrace apis for magento.


texts: Magento Redirects To Homepage When Not Adding HTTPS

texts:
Recently we made a change to our domain to force WWW and HTTPS. However, I notice now if I type a url without the https it redirects to homepage. Is this something that can be fixed in .htaccess?

Try this: therapydogvest.com/service-dog-vests.html
It should be going to this page https://www.therapydogvest.com/service-dog-vests.html

We are on Magento 1.9.3.2


texts: Magento: get variable from custom Model in a phtml file

texts:
I'm trying without success to get a custom variable (from a custom function and a custom Module).

That's why I have tried (in a .phtml file) :

$myModel = Mage::getModel('mymodule/MyClass');
$myVar = $myModel->myCustomFunction();
var_dump($myVar);

but I get always NULL;

When I write a var_dump in the function I get see the wanted value of the variable, but that don't works in the template file.


texts: How to Add Custom fields to Checkout page in Magento2

texts:
I need to add two custom fields in each shipping and payment steps of checkout page in Magento 2 and also data should be saved in needed tables

how to do it in Magento 2


texts:
My product comparison link doesn't work. This is in Magento 1.9.

My issues are almost identical to this post, with the exception that clearing the index did not work. Is there anything else I can try?

Here are the issues:

When I click "Add to Compare" on a product, a message stating that "such-and-such product successfully added to compare list" appears.

However the compare products sidebar shows "You have no items to compare."

I can tell the table catalog_compare_item is being populated with the correct visitor ID and product ID, but if I do a print_r($this->helper('catalog/product_compare')->getItemCount()) in template/catalog/product/compare/sidebar.phtml, "0" is returned.

Why won't the sidebar show the products to compare?