texts: Get New Products List from specific Category with Widget in CMS

texts:
Is there any way to get New Products List from specific Category with Widget in CMS Pages? I have tried specifying category ID using category_id="12" but it is pulling latest products from all the categories.

Below is the Widget code which I am using:

{{widget type="catalog/product_widget_new" category_id="12" products_count="4" template="catalog/product/widget/new/content/new_grid.phtml"}}


texts:
I started a new Magento 2 project and i always keep my projects in bitbucket...
When i added the files to push i got like 200Mb of files is it really necessary to keep a Magento 2 project in a repository?

I am using this .gitignore file


texts: How do you hide and show specific menu items based on a set cookie in 1.9

texts:
First off I have found this site SUPER helpful in the past dozen years for my days working with Oscommerce and now with Magento. So thanks to all the contributors to stackexchange.  I am only 6 months in with Magento now and want to do things the right way and not code around the features and proper methods in Magento.

Ok, so I know how to set a cookie for what I am doing I just need to know the best way to change a menu button.  Basically I am trying to accomplish the following.

Show a menu item which I currently have that says "Select Vehicle" and once selected I have it set a cookie already.  Here is the part I need help with. I would like to then have that same menu item show up as "Shop Now".   I think the best way is to make both buttons and have them do what I want them to do and then make one visable and the other not visable based on the cookie set?  Or is there a better way.  So far I have conformed to Magento by only messing with my theme and by adding CMS blocks and what not.  Obviously I could "hard code" this but I know this is bad in case of a future migration.  So yeah help me with ideas and approaches please to accomplish this.

Thanks in advance.


texts: Override protected function of block class in Magento 2.1.7

texts:
I want to override a protected function getOptionPrices() of class {root_folder}\vendor\magento\module-configurable-product\Block\Product\View\Type\Configurable.php. I have written following code.

{root_folder}\app\code\Company\Module\etc\di.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Magento\ConfigurableProduct\Block\Product\View\Type\Configurable" type="Company\Module\Block\Product\View\Type\Configurable" />
</config>

{root_folder}\app\code\Company\Module\Block\Product\View\Type\Configurable.php

<?php
/**
 * Catalog super product configurable part block
 *
 * Copyright © 2013-2017 Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
namespace Company\Module\Block\Product\View\Type;

use Magento\ConfigurableProduct\Model\ConfigurableAttributeData;
use Magento\Customer\Helper\Session\CurrentCustomer;
use Magento\Framework\Pricing\PriceCurrencyInterface;

/**
 * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
 */
class Configurable extends \Magento\ConfigurableProduct\Block\Product\View\Type\Configurable
{
    public function __construct(
        \Magento\Catalog\Block\Product\Context $context,
        \Magento\Framework\Stdlib\ArrayUtils $arrayUtils,
        \Magento\Framework\Json\EncoderInterface $jsonEncoder,
        \Magento\ConfigurableProduct\Helper\Data $helper,
        \Magento\Catalog\Helper\Product $catalogProduct,
        CurrentCustomer $currentCustomer,
        PriceCurrencyInterface $priceCurrency,
        ConfigurableAttributeData $configurableAttributeData,
        array $data = []
    ) {
        parent::__construct(
            $context,
            $arrayUtils,
            $jsonEncoder,
            $helper,
            $catalogProduct,
            $currentCustomer,
            $priceCurrency,
            $configurableAttributeData,
            $data
        );
    }

    protected function getOptionPrices()
    {
        $customHelper = \Magento\Framework\App\ObjectManager::getInstance()->get('\Company\Module\Helper\CustomHelper');

        $prices = [];
        foreach ($this->getAllowProducts() as $product) {
            $priceInfo = $product->getPriceInfo();
            $stock = $customHelper->getStockData($product->getId());
            $prices[$product->getId()] =
                [
                    'oldPrice' => [
                        'amount' => $this->_registerJsPrice(
                            $priceInfo->getPrice('regular_price')->getAmount()->getValue()
                        ),
                    ],
                    'basePrice' => [
                        'amount' => $this->_registerJsPrice(
                            $priceInfo->getPrice('final_price')->getAmount()->getBaseAmount()
                        ),
                    ],
                    'finalPrice' => [
                        'amount' => $this->_registerJsPrice(
                            $priceInfo->getPrice('final_price')->getAmount()->getValue()
                        ),
                    ],
                    'min_qty' => $stock['minQty'],
                    'max_qty' => $stock['maxQty']
                ];
        }
        return $prices;
    }
}

Above code is not working. Please help me.


texts:
I have uploaded one of my projects in the server which is in magento 1.9. I have changed the base_url all details in the database. But there is an error, the error is shown below :

  Exception during cache and session cleaning: Error in file: "/home/pxxxs/public_html/app/code/community/SorenInfotech/ProductInquiry/sql/productinquiry_setup/mysql4-install-0.1.0.php" - SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'productinquiry' already exists

Can anyone know how to solve this ? Module "ProductInquiry" show in admin panel but cant show on product page.


texts: How to get response (email , user_info) after login with Facebook? Magento 2

texts:
I am trying to allow login from Facebook without popup, not able to get the response from Facebook.

Here is my fb login link:

FB LOGIN

I am able to redirect to my controller but unable to get the response.
These are the things i have tried:

$this->request->getParam('email');

$this->getRequest()->getQuery('email');

In both ways not getting any response. Please help me resolve this issue, Thanks in Advance.


texts: Hide Shipping Method Title from Order Summary

texts:
In order summary (Cart page), Shipping Method is displayed as:

(Method Name - Method Title)

Is it possible to remove Method Title and display just the Name?


texts: Admin No functions working Attention Something went wrong

texts:
Magento 2.3.5p
Suddenly my well working site has a error in admin, the public site is working with out any issues
I log in top admin and i get
Attention Something went wrong.
A technical problem with the server created an error. Try again to continue what you were doing. If the problem persists, try again later.
This happens on every admin page I go to.
Catalog Products message =Something went wrong with processing the default view and we have restored the filter to its original state.
And will not load any products
Catalog category Attention Something went wrong.and can not add delete edit
So backend is not functioning
I have Tried every offered solution re SSH composer deploy flush upgrade etc and in some cases when finished the site is worse i get no icons and can nt access menus (I then have to restore a backup to continue)
Created Clone same issues
I have disbled add on extensions clear var folder
made changes to database as suggested
Increased memory
Checked php version
I am at wits end as up too now I have solved every issue that has been thrown at me
Help


texts: How to Make First and Last Name Optional for addresses?

texts:
I have a Magento 2.15 site that almost exclusively sells B2B. We don't have many customers that are just individuals. 99% of them are businesses.

So when checking out, the people that order for their business understandably don't want to put a first and last name in for the billing or shipping address. Some of them just type "none" for both boxes and then proceed to put the company name in the company name box.

How can I make the First and Last name fields optional? Will this possibly have rammifications elsewhere? I know Magento 2 is weird about addresses as I've had issues with default addresses causing errors in the past.

TL:DR How do I make "First Name" and "Last Name" fields optional when entering both shipping and billing addresses? It should also be done on any other places where an address is entered, like registration.

Thanks


texts: Add validated list of patients to customer account during checkout

texts:
I'm struggling to find the best approach to achieve what I need.
I have a store that sells contact lenses. For lenses shipped to United States I need the customer prescription to be validated by an approved doctor. So the customer enters his doctor's details and a call is made to the doctor: if the doctor confirms the order, the order is shipped, otherwise the order is refused. The first time the order is confirmed, all subsequent orders with same details are automatically valid for the next year, so on the second order the customer should not need to enter the same doctors details again, because his prescription is already validated. What I tried so far:

saving the doctor's details on the account information or in the billing address: this works only if the magento user (buyer) is also the person who will use the lenses. This doesn't work if the magento user wants to buy a present for somebody  else: the doctors details of this second person should be added because the second person is the user of the lenses but the doctors details are link to the account or the billing address, which have nothing to do with the end user contained in the shipping address).
saving the doctor's details on the shipping address: this works if the buyer is also the end user of the lenses and it works if the buyer wants to buy for someone else, but it does not work if the buyer is also the end user and wants to ship to another location (eg: the buyer lives in alabama, he's going to spend a few days in alaska and wants his lenses to be shipped in alaska. The doctor's details should not be linked to the alaska address, they should be linked to the alabama address because that's where the doctor of the buyer/end-user is)
saving the doctor's details on the order: this doesn't work because I have no parameters to keep the validation for a year, so the user would be forced to enter the doctor's details everytime he places an order.

I have also thought to create a custom table in the database and put the doctor's details there but I still don't know how to link the details to the customer so that the user has to enter them only once and they will be valid for the next year.

Another solution would be to create a custom form the magento user can use to add all the doctors he needs, then in the checkout a dropdown would list them as options. But if the user doesn't have the doctors already in the list he has to leave the checkout, go to the custom form to enter the doctor, then go back to the checkout. It's too long so I hope there is a better way.

So basically what I need to achieve is:
- the magento user buys for himself and ships to himself = he adds his own doctor
- the magento user buys for himself but he ships to a different location = he add his own doctor
- the magento user buys for somebody else and ships to the second person = he adds the doctor of the second person
- the buyer needs to enter the doctor only the first time: if the call validates his order, the validation needs to be valid for a year (so all the other orders with the same details are already validated)

Any suggestions?

Thanks


texts: What type of Inheritance is better for customizing code?

texts:
I am trying to customize the catalog and sales/order grids in magento.

There are 3 ways I know, by which I can implement by custom logic on these grids:

  Multilevel inheritance

for example

class Mage_Adminhtml_Block_Catalog_Product_Grid extends Mage_Adminhtml_Block_Widget_Grid{
    ...
    ...
}

and I use

class Royal_Marketplace_Block_Adminhtml_Catalog_Product_Grid extends Mage_Adminhtml_Block_Catalog_Product_Grid{
    ....
    // override only the methods I want to customize
}

  Single inheritance by many classes

for example

class Mage_Adminhtml_Block_Catalog_Product_Grid extends Mage_Adminhtml_Block_Widget_Grid{
    ...
    ...
}

and I use

class Royal_Marketplace_Block_Adminhtml_Catalog_Product_Grid extends Mage_Adminhtml_Block_Widget_Grid{
    ....
    // reproduce all the functions
}

  Events n Observers

If I don't use events and observers for some reason, I have 2 questions:

Is my understanding correct?
Which one is better among the first two methods? (I think 1st method is preferable, but many say 2nd is better).


texts: How to setup CI on Magento 2 extension using Bitbucket Pipeline?

texts:
How can I prepare a CI script to check the syntax and code quality of my extension code?

It's not necessary to run Unit Test or Integration Test, I'm using Bitbucket and I would like to use Bitbucket Pipelines.


texts:
We have a strange behavior in our store in the mini cart. If I add some items to cart then navigate somewhere and after couple minutes content of mini cart disappears. If I add something again to mini cart - I will see all my previous items again.

Our team checks https settings (all store under https), cookie settings, session settings, cache settings etc. Nothing helps. Same thing always.
Any thoughts what it could be?

M2 version: 2.1.2


texts:
How to do Brand activation feature on Product page in magento?

When I click on one product, that product page opened. When I click brand under product name, it is not working.

It must show all products related to that brand name.

Please help me urgent.


texts: Should Magento\Eav\Model\AttributeRepository save 'used_in_forms' attribute value?

texts:
I add EAV attribute to a customer address.
I can use \Magento\Customer\Model\ResourceModel\Attribute $attributeResource to save the attribute.

According to Magento DevDocs https://devdocs.magento.com/guides/v2.3/extension-dev-guide/attributes.html

/** @var \Magento\Eav\Api\Data\AttributeInterface $attribute */
$attribute->setData('used_in_forms', ['adminhtml_customer']);
$attributeResource->save($attribute);

It works.

I'm trying to use Magento\Eav\Model\AttributeRepository to save the attribute.

The repository contains a method

    public function save(\Magento\Eav\Api\Data\AttributeInterface $attribute)
    {
        try {
            /** @var \Magento\Eav\Model\ResourceModel\Entity\Attribute */
            $this->eavResource->save($attribute);
        } catch (\Exception $e) {
        ...
    }

and I see the attribute in eav_attribute database table but there are no records in the table customer_form_attribute.

Maybe someone can explain why?

Code example:

use Magento\Customer\Api\AddressMetadataInterface;
use Magento\Eav\Api\AttributeRepositoryInterface;
use Magento\Eav\Model\Config as EavConfig;
use Magento\Eav\Setup\EavSetupFactory;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;

....
    /**
     * @param ModuleDataSetupInterface $moduleDataSetup
     * @param EavSetupFactory $eavSetupFactory
     * @param EavConfig $eavConfig
     * @param AttributeRepositoryInterface $attributeRepository
     */
    public function __construct(
        ModuleDataSetupInterface $moduleDataSetup,
        EavSetupFactory $eavSetupFactory,
        EavConfig $eavConfig,
        AttributeRepositoryInterface $attributeRepository
    ) {
        $this->eavSetupFactory = $eavSetupFactory;
        $this->moduleDataSetup = $moduleDataSetup;
        $this->eavConfig = $eavConfig;
        $this->attributeRepository = $attributeRepository;
    }

    /**
     * @inheritdoc
     */
    public function apply()
    {
        /** @var \Magento\Eav\Setup\EavSetup $eavSetup */
        $eavSetup = $this->eavSetupFactory->create(['setup' => $this->moduleDataSetup]);

        $attributeCode = 'test_attribute';

        $entityTypeId = AddressMetadataInterface::ENTITY_TYPE_ADDRESS;
        $setId = AddressMetadataInterface::ATTRIBUTE_SET_ID_ADDRESS;
        $eavSetup->addAttribute($entityTypeId, $attributeCode, [
            'type' => 'int',
            'input' => 'boolean',
            'label' => 'Test attribute',
            'required' => 0,
            'user_defined' => 1,
            'default' => 0,
            'system' => 0,
            'position' => 60,
        ]);

        $eavSetup->addAttributeToSet($entityTypeId, $setId, null, $attributeCode);

        $attribute = $this->eavConfig->getAttribute($entityTypeId, $attributeCode);
        $attribute->setData('used_in_forms', [
            'adminhtml_customer_address',
            'customer_address_edit',
            'customer_register_address'
        ]);

        // works. deprecated, I remember
        // $attribute->getResource()->save($attribute);

        // the attribute is saved, but the information on the forms in which the attribute is added is not saved
        $this->attributeRepository->save($attribute);
    }


texts: EOFException while calling Ksoap2 magento api

texts:
I am getting EOFEXCEPTION while calling ksoap2 magento apis. mainly while call productinfo

request = new SoapObject(NAMESPACE, name);
request.addProperty("sessionId", "anksf123123123");
  env.setOutputSoapObject(request);
androidHttpTransport = new HttpTransportSE("http://testdomain.com/Mage3.php");
        androidHttpTransport.call("", env);
         Object object = env.getResponse() ;
        System.out.println(object.toString());

I am getting error :

07-30 12:48:45.204: W/System.err(21083): java.io.EOFException
07-30 12:48:45.204: W/System.err(21083):    at com.android.okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:95)
07-30 12:48:45.204: W/System.err(21083):    at com.android.okhttp.internal.http.HttpConnection.readResponse(HttpConnection.java:179)
07-30 12:48:45.204: W/System.err(21083):    at com.android.okhttp.internal.http.HttpTransport.readResponseHeaders(HttpTransport.java:101)
07-30 12:48:45.204: W/System.err(21083):    at com.android.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:628)
07-30 12:48:45.209: W/System.err(21083):    at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:388)
07-30 12:48:45.209: W/System.err(21083):    at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:332)
07-30 12:48:45.209: W/System.err(21083):    at com.android.okhttp.internal.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:199)
07-30 12:48:45.209: W/System.err(21083):    at org.ksoap2.transport.ServiceConnectionSE.openInputStream(ServiceConnectionSE.java:113)
07-30 12:48:45.209: W/System.err(21083):    at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:167)
07-30 12:48:45.209: W/System.err(21083):    at com.outthinking.utils.SOAPServiceForCustomAPI.sendRequest(SOAPServiceForCustomAPI.java:74)


texts: Some SKUs not returning the product details through REST API using get / update method in Magento2.1.3

texts:
Am trying to update the product details from third party machine to magento 2.1.3 using REST API.
here some of the SKUs not returning the details while get/update and then i logged that SKUs and checked in admin, it was available.

I dont know is there any mistake in skus fomrats.

Magento admin allowed to save the products using these kind of sku formats(ABCD (20-B), ABCD/20) in admin side :), we have many SKUs like that.

Details:

Requested url: http://{base url}/index.php/rest/all/V1/products/{sku} using OAuth 1.0

Method: GET

Skus list   | response:
ABCDE       | {"id":123,....}
ABCD123     | {"id":123,....}
ABCD (20-B) | {"message": "Invalid signature"}

Is any sku format suggested by magento doc?

Please suggest any solution to get works.

Thanks


texts: Is there any option to give discounts on products, based on ratios

texts:
My current site is on jewellery. I want to give discounts based on diamond and metal weight's ratio.

Ex -
1 : 0.25   - Discount 25%
1 : 0.20   - Discount 20%

In admin is there any option or I will have to customize?


texts:
How can i redirect my magento page with urlkey in my controller
i just made custom form that save data in database

after submit data i want to redirect to same page where that data sent

but want url like

localhost/b/index.php/sony-vaio-vgn-txn27n-b-11-1-notebook-pc.html/


texts: Custom image attribute not saving programmatically in Magento2

texts:
I have created a custom image type attribute. And trying to set image from code. But it is showing random behaviour.

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
        $fileSystem = $objectManager->create('\Magento\Framework\Filesystem');
        $mediaPath=$fileSystem->getDirectoryRead(\Magento\Framework\App\Filesystem\DirectoryList::MEDIA)->getAbsolutePath();

$id = '123'; // YOUR PRODUCT ID;
            $product = $objectManager->create('Magento\Catalog\Model\Product')->load($id); // Load product object

            $sku = $product->getSku();

            $imageAssign = $mediaPath.'catalog/product/image.png';

            if (file_exists($imageAssign )) {
                $product->addImageToMediaGallery($imageAssign, array( 'my_flipper_image' ), false, false);
                $imageset = $mediaPath.'catalog/product/'.$sku[0].'/'.$sku[1].'/image.png';
                $product->setMyFlipperImage($imageset)->save();

            }


texts: Magento2: Index page running problem (index source code displaying)

texts:
I have complete installation&run successfully magento2 package some days ago...

But, Now I trying to run the package

index.php source code was displaying while executing the magento2 package.

i try the URL 127.0.0.1/magento2_package/home ---> It's Correctly working,

And

Admin side URL 127.0.0.1/magento2_package/admin--->Correctly working,

This URL 127.0.0.1/magento2_package/  ---> It's shown the index.php source code.

Please give any solution or link for solve that issue...


texts:
I wish to remove password-strength-indicator.js and zxcvbn.js  from customer module, because it takes 1 MB to load and takes more time.
So Please provide me a solution to remove the above js what i have mentioned.


texts:
I have been working with magento, our store only uses bundle products, and as we have started to have a large amount of data (10,000 simple products) (around 1500 bundle products)

I Have noticed that saving and requesting has become a lot larger, when I have ran the Mysql request check I can see then when selecting 'bundle items' in the product screen it will request every single, single product within the database.

I was wondering if anyone has come across the same problem or issue?

UPDATE

I have also installed a basic version of magento 1.6.2 which we are using, and copied the data base to see if it was a module confliction, still the bundle is searching for 10,000 entity i'ds before proceeding to the next page.


texts: Magento2: Add pricing logic layer at the end

texts:
Before moving to Magento, I had a princing logic inside a table that involved (customer, customer group, item, item group, etc)

There are some native features that I will take advantage of such as tier prices and some more.

But in the end I will have to add some custom funcionalities about princing.
I was thinking about adding a custom layer at the end of calculating prices.
What I mean is, Magento calculates prices by layers, aproximately:

Regular price > Tier price > Special Price

I would want to add my layer at the end.

For testing I only wanted to add this layer and set the price to 5€ for example. Just for know that is working. When I have this, for me it will be the solution

The documentation is not helping so much: http://devdocs.magento.com/guides/v2.1/architecture/behavior/pricing.html

What I've done:

Created my custom module.
Added my logic pricing class, based on:

vendor/magento/module-catalog/Pricing/Price/SpecialPrice.php

vendor/magento/module-catalog/Pricing/Price/SpecialPriceInterface.php

namespace Gsp\SpecialPrices\Pricing\Price;

/**
 * Custom price interface
 */
interface CustomPriceInterface
{
    /**
     * Returns custom price
     *
     * @return float
     */
    public function getCustomPrice();

    /**
     * @return bool
     */
    public function isPercentageDiscount();
}

namespace Gsp\SpecialPrices\Pricing\Price;

class CustomPrice extends AbstractPrice implements CustomPriceInterface, BasePriceProviderInterface
{
    /**
     * Price type special
     */
    const PRICE_CODE = 'custom_price';

    /**
     * @return bool|float
     */
    public function getValue()
    {
        return 5;
    }

    /**
     * Returns special price
     *
     * @return float
     */
    public function getCustomPrice()
    {
        return 9;
    }

    /**
     * @return bool
     */
    public function isPercentageDiscount()
    {
        return false;
    }
}

Don't worry about the 5 or 9, I don't know what the heck am I doing. lul.
I only want to set the prices the amount I want.

di.xml, adding my custom price:

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <virtualType name="Magento\Catalog\Pricing\Price\Pool" type="Magento\Framework\Pricing\Price\Pool">
        <arguments>
            <argument name="prices" xsi:type="array">
                <item name="regular_price" xsi:type="string">Magento\Catalog\Pricing\Price\RegularPrice</item>
                <item name="final_price" xsi:type="string">Magento\Catalog\Pricing\Price\FinalPrice</item>
                <item name="tier_price" xsi:type="string">Magento\Catalog\Pricing\Price\TierPrice</item>
                <item name="special_price" xsi:type="string">Magento\Catalog\Pricing\Price\SpecialPrice</item>
                <item name="base_price" xsi:type="string">Magento\Catalog\Pricing\Price\BasePrice</item>
                <item name="custom_option_price" xsi:type="string">Magento\Catalog\Pricing\Price\CustomOptionPrice
                </item>
                <item name="configured_price" xsi:type="string">Magento\Catalog\Pricing\Price\ConfiguredPrice</item>
                <item name="custom_price" xsi:type="string">Gsp\SpecialPrices\Pricing\Price\CustomPrice</item>
            </argument>
        </arguments>
    </virtualType>
</config>

Now the website is broken when I go to a product list or product view. It breaks exactly when it has to render the price. So I guess is working what I did but I'm missing something.

The log is showing that error:

main.INFO: Cache file with merged layout: LAYOUT_frontend_STORE1_56f1b068ec7ccf4878f9284dd1137afd1 and handles catalog_product_prices: Please correct the XML data and try again.  [] []

But I see this error is also displayed when I disable my module.
I have porto theme, and there isn't any layout named catalog_product_prices.xml


texts: Run Magento 2 On low end system resources,

texts:
I saw a system with below configuration :-

dual core processor
8 gb ddr3 Ram
240 gb SSD
windows 10

I've tried to run Magento 2 in it using Bitnami stack, but its very slow.
Is their any other way or Virtual system available to install magento in it & use it for development ?
A little better speed would be better then very slow speed.
Feel free to share thoughts.
Thankyou


texts: Upload file option on product detail page

texts: I want to give UPLOAD FILE OPTION on product detail page where customer can upload files and admin can get files from backend. is it possible?


texts:
Can anyone point me in the direction (github or magento connect) of any well written modules in terms of code/architecture and not functionality?

Preferably also using unit tests or magespec.

It seems there is a sea of poorly coded modules out there and i am looking for some solid examples.

Also to note that i am aware of the judge app but im more interested in other developers actual knowledge on this.


texts: Table "Only X Left" on product page doesn't show product names (only Qty) in Magento 1.9.1.0

texts:
The issue is also described on Magento Bug-track (still not answered):
http://www.magentocommerce.com/bug-tracking/issue/index/id/443
Steps to reproduce:
I have created a configurable product consisting of 3 Simple products (hidden individually) with different Stock quantities. When looking at the frontend and having the option: "Only X left" displayed, the quantity is correct. When I expand to display the details, the table is displayed but does not contain the names of the individual Simple products. I have tested this with a clean install of 1.9.0.1 which works correctly I have tested this with a clean install of 1.9.1.0 and the information is missing.
Expected Result:
Only X left table in the frontend with a breakdown of the Name of the Simple products per row and the Qty of that product in the column behind it Actual Result: Only X left table in the frontend consists of the correct amount of rows and columns. The name column does not display the product name, the Qty column displays the correct information.
Does anyone know how to fix this bug?
This is how it looks like in Magento 1.9.1.0:

And this is how it should look like (from Magento 1.9.0.1):


texts: /rest/V1/carts/:cartid/payment-information code is not working. The request does not match any route. Please suggest something.


texts: Rename shipping address into delivery address-magento2 checkout page

texts: In my checkout page,i need to rename shipping address.i used IWD free extenstion for one step checkout.here with i enclose the screenshot and link to IWD free one step checkout link.Refer(https://www.iwdagency.com/extensions)


texts: Difference b/w 1.9.0.1 vs 1.9.2.0 with related to Paypal

texts:
we configured paypal for 1.9.0.1 version with merchant country India.

we can see "Paypal website payments standard" option

but in 1.9.2.0 version, we have "Paypal website payments standard (include express checkout )"

In 1.9.0.1 its going for "order review step" but in 1.9.2.0 its skipping order review step. I dont want to skip order review step in 1.9.2.0 also.


texts: Magento 2: Add class to pre existing xml container

texts:
How do you add a class to a pre existing xml block?

Example:

<container name="alert.urls" as="alert_urls" label="Alert Urls" after="product.price.tier"/>
            <block class="Magento\Catalog\Block\Product\View" name="product.info" template="product/view/form.phtml" after="alert.urls">
</container>


texts: programmatically adding a multilingual product

texts:
I am writing an import script that is going to loop through some records and add products. I have it adding the products nicely but my store is multilingual so each product needs and english or a spanish name depending on which store is being viewed.

Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$product = Mage::getModel('catalog/product');
try{
$product

    ->setWebsiteIds(array(1))
    ->setStoreId(0)
    ->setAttributeSetId(4)
    ->setTypeId('bundle')
    ->setName($en_title)
    ->setCreatedAt(strtotime('now'))
    ->setSku('resource'.$resource_id)
    ->setStatus(1)
    ->setTaxClassId(0)
    ->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)
    ->setPrice(number_format($price, 2, '.', ''))
    ->setStockData(array(
                       'use_config_manage_stock' => 0,
                       'manage_stock'=>0,
                   )
    )
    ->setCategoryIds(array(51))
    //->save()
    ->setStoreId(1)
    ->setName($en_title)
    //->save()
    ->setStoreId(2)
    ->setName($es_title)
    ->save();
}catch(Exception $e){
Mage::log($e->getMessage());
}

My English store had an ID of 1, and my Spanish store has an ID of 2. When I use the posted code all names are in Spanish regardless of store, and when I uncomment the save functions then all names are in English. I can't figure out why it wont save my Spanish name under my spanish store and my English name as Default and under the English store.


texts: Price calculator for small wine e-shop with multiple warehouses in different countries

texts:
Problem:

My friend runs some small wineries in Italy and owns 3-4 small warehouses in different European countries. He wants his online customers (wine buyers) to decide from which warehouse they want to get the wine, by comparing shipment prices.

If customer is located in the same country as warehouse, it's highly preferable to have integration with local delivery services and online payment systems.

Currently I'm leaning towards Magento 2.3 + PWA Studio.

Question:

Is it possible to achieve this functionality of such price calculator without creating custom module?


texts: magento 2 : where is Layout XML File for Homepage located

texts:
\vendor\magento\module-catalog\view\frontend\layout\catalog_product_view.xml
is the layout xml file for Product Detail Page.

Where are the layout xml files for Homepage and for Category Page (page that shows after clicking on a category link ex. 'http://127.0.0.1/magento/category-1.html', where layered navigation is displayed) ?

what I mean by Catgory Page:

thanks


texts: Custom product attribute storefront property 'Used for Sorting in Product Listing' is disabled

texts:
Stores > Attributes > Product > My Custom Attribute > Storefront Properties tab

I'm not able to change the Storefront Properties 'Used for Sorting in Product Listing', since it is disabled or grayed out.

What is the reason behind it ? How can I fix this ?
Updated
Script used below and version is Magento Commerce 2.4.0
          $attributeData  = [
            'attribute_code'                => $formattedCode,
            'is_global'                     => 1,
            'frontend_label'                => $replAttribute->getDescription() ?: $replAttribute->getCode(),
            'frontend_input'                => $frontendInput,
            'is_unique'                     => 0,
            'apply_to'                      => 0,
            'is_required'                   => 0,
            'is_configurable'               => 0,
            'is_searchable'                 => 1,
            'is_comparable'                 => 1,
            'is_user_defined'               => 1,
            'is_visible_in_advanced_search' => 0,
            'is_used_for_price_rules'       => 0,
            'is_wysiwyg_enabled'            => 0,
            'is_html_allowed_on_front'      => 1,
            'is_visible_on_front'           => 1,
            'used_in_product_listing'       => 0,
            'used_for_sort_by'              => 1,
            'backend_type'                  => 'varchar',
            'backend_model'                 => ArrayBackend::class,
            'is_filterable'                 => ($frontendInput === 'multiselect') ? 1 : 0,
            'is_filterable_in_search'       => ($frontendInput === 'multiselect') ? 1 : 0
        ];


texts: Magento : How to Add Quantity Box in Custom Option for Simple Product

texts:
I have a attribute "size" which have drop down option in custom option admin panel, and i want to show quantity box for this option, our all products are simple products.

I have tried below link it will not work fully
http://hkpatel201.blogspot.in/2014/03/how-to-add-custom-qty-to-custom-option.html

I am trying the below code

  1.go to app\design\adminhtml\default\default\template\catalog\product\edit\options\type\select.phtml

  Find the below code:
 '<?php echo Mage::helper('catalog')->__('SKU') ?>	'+

  Now add following code just after above code.
 '<?php echo Mage::helper('catalog')->__('Qty') ?>	'+

  Find the below code:
  '<input type="text" class="input-text" name="product[options][{{id}}][values][{{select_id}}][sku]" value="{{sku}}">	'+

  Now add following code just after above code.
  '<input type="text" class="input-text" name="product[options][{{id}}][values][{{select_id}}][qty]" value="{{qty}}">	'+

  2. go to app\code\core\Mage\Adminhtml\Block\Catalog\Product\Edit\Tab\Options\Option.php

  Find the below code:
  $value['sku'] = $this->htmlEscape($option->getSku());

  Now add following code just after above code.
  $value['qty'] = $this->htmlEscape($option->getQty());

  Find the below code:
  'sku' => $this->htmlEscape($_value->getSku()),

  Now add following code just after above code.
  'qty' => $this->htmlEscape($_value->getQty()),

  3. Add field in “catalog_product_option_type_value” table in database
  `qty` int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'Qty',

After adding this code the quantity box showing in admin panel in custom option and quantity is also save in database.

But problem is this it will not validate quantity in frontend also in stock .


texts: Magento 2 - Incorrect title showing for some pages

texts:
Some of the pages show incorrect title and heading : it is showing "Customer Login" as page heading and title for Contact page and Advanced Search page.

The point is, I included customer login form on every page including these above, but anywhere else I can edit the page title successfully...

How to edit these pages title and heading ?


texts: Convert environment emulation v.1.9 to v.2

texts:
How to rewrite below code to fix version 2.0

$initialEnvironmentInfo = $appEmulation->startEnvironmentEmulation($storeId);

//Dealing with uninitialized translator!
Mage::app()->getTranslator()->init('frontend', true);

Thank you.


texts: Want to overwrite minicart/item/default.html file for minicart?

texts:
I want to hide qty box and remove/delete icon from mini cart for few products. For this I overwrite checkout_cart_sidebar_item_renderers.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>
        <referenceBlock name="minicart">
            <arguments>
                <argument name="jsLayout" xsi:type="array">
                    <item name="components" xsi:type="array">
                        <item name="minicart_content" xsi:type="array">
                            <item name="children" xsi:type="array">
                                <item name="item.renderer" xsi:type="array">
                                    <item name="component" xsi:type="string">uiComponent</item>
                                    <item name="config" xsi:type="array">
                                        <item name="displayArea" xsi:type="string">defaultRenderer</item>
                                        <item name="template" xsi:type="string">Custom_Module/minicart/item/default</item>
                                    </item>
                                </item>
                            </item>
                        </item>
                    </item>
                </argument>
            </arguments>
        </referenceBlock>
    </body>
</page>

Then create default.html file under
Custom/Module/view/frontend/web/template/minicart/item/default.html

But after doing this I found minicart is blank. like below image.
Can you please help me to understand my mistake?


texts:
How can I add a custom variable to a email template in Magento 2 ?

I know that I can generate custom variables with HTML output but I want to output some PHP code.

I want to echo the date of the order in the email.

Thanks in advance!

EDIT:
Please note that I'm editing the email template in the admin section of the website. Not directly in the PHTML file.


texts: How to disable/redirect shopping cart page to checkout page

texts:
I'm using magento 2.3.X , how can i disable/redirect shopping cart page to checkout page.
now is httsp://xxx.com/checkout/cart/ but i want to skip checkout/cart change to checkout page.
Thank you!


texts: JPG product images won't display but PNG will

texts:
A old client of mine has come to me because most of her product images have stopped being displayed on her site.

After some investigation it seems that if a product image is a png file, it displays, if it is a jpg it doesn't.

Jpgs that are part of the theme (e.g. the credit card symbols in the footer) are showing ok.

I've flushed the images cache.  The permissions on the media\catalog\product.. folders are set to 0777. The files are definitely on the server and the product page seems to be calling the correct file. I can't see anything wrong with the pathing.

I've deleted one and reuploaded the same image to the same product as both jpg and png, and only the png will load.

See this product for example:
http://www.justcardsdirect.com/happy-anniversary-no-verse.html

Can anyone suggest what I could try in order to fix this?
Thank you.


texts: Adding Custom tab to product page dependant on category in Magento 2.2.1

texts:
I have used the following code

  (https://www.cloudways.com/blog/add-custom-tab-product-page-magento-2/)

to create a module that adds a custom tab to our product pages. It works perfectly but I need to somehow change the module so that the custom tab only display on products in certain categories. Has anyone any suggestions on how to do this? Don't mind if the category numbers need to be hard coded as there won't be many! Please note we are using Magento 2.2.1

David


texts: Magento 2 Load database value to custom field in product attribute

texts:
I am adding a custom field to product attributes with a plugin providing the adminhtml display.

I have it visible in Store -> Attributes -> Product -> Edit attribute and it works okay to save, but when editing a product attribute the stored value is not loaded. The value is initially correctly stored in the database, subsequent visits to edit do not load the saved value from the database.

How can I have this yesno successfully pull the stored value when an admin is editing the attribute?  I'm not sure why the value isn't being pulled with the current one being selected.  This is Magento 2.2.7

  CompanyName\ModuleName\Setup\UpgradeSchema.php

<?php
namespace CompanyName\ModuleName\Setup;
use Magento\Framework\Setup\UpgradeSchemaInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\SchemaSetupInterface;
class UpgradeSchema implements UpgradeSchemaInterface{
 public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context){
 if (version_compare($context->getVersion(), '1.0.1') < 0) {
 $setup->startSetup();
 $setup->getConnection()->addColumn(
 $setup->getTable('catalog_eav_attribute'),
 'my_custom_field',
 ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
 'length' => '1',
 'nullable' => false,
 'unsigned' => true,
 'default' => '0',
 'comment' => 'This is a custom field']);
 $setup->endSetup();
 } } }

  CompanyName\ModuleName\Plugin\Block\Adminhtml\Product\Attribute\Edit\Tab\Front.php

<?php
namespace CompanyName\ModuleName\Plugin\Block\Adminhtml\Product\Attribute\Edit\Tab;

class Front
{

    /**
     * @var Yesno
     */
    protected $_yesNo;

    /**
     * @param Magento\Config\Model\Config\Source\Yesno $yesNo
     */
    public function __construct(
        \Magento\Config\Model\Config\Source\Yesno $yesNo
    ) {
        $this->_yesNo = $yesNo;
    }

    /**
     * Get form HTML
     *
     * @return string
     */
    public function aroundGetFormHtml(
        \Magento\Catalog\Block\Adminhtml\Product\Attribute\Edit\Tab\Front $subject,
        \Closure $proceed
    )
    {

        $yesnoSource = $this->_yesNo->toOptionArray();
        $form = $subject->getForm();
        $fieldset = $form->getElement('front_fieldset');
        $fieldset->addField(
            'my_custom_field',
            'select',
            [
                'name' => 'my_custom_field',
                'label' => __('Label for my custom field'),
                'title' => __('Title for my custom field'),
                'note' => __('Note for my custom field.'),
                'values' => $yesnoSource,
            ]
        );
        return $proceed();
    }
}

  CompanyName/ModuleName/etc/adminhtml/di.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Catalog\Block\Adminhtml\Product\Attribute\Edit\Tab\Front">
        <plugin name="companyname_attribute_edit_form" type="CompanyName\ModuleName\Plugin\Block\Adminhtml\Product\Attribute\Edit\Tab\Front" sortOrder="1"/>
    </type>
</config>


texts: Magento2 - Add customer email address in order email

texts:
I'm trying to add customer email address under the billing section of transactional email.

For transactional email I tried
this solution

but it is not working.

I also tried to add whith no success that variable under Customer Address Templates.

Any ideas?


texts: Updating Magento to 2.2.2: errors on block attributes

texts: I'm trying to update Magento 2.1.8 to 2.2.2. After the update I get errors about block attributes on layouts.


texts: How to Reproduce Multiple Product Setting Changes

texts:
Here's what I'm trying to do. I have a process that I've manually written out for "Discontinuing" a product on our site. E.g. Remove from all categories, change "Brand" to "Discontinued," set stock to "Discontinued," etc.

This can be done with some efficiency/consistency via CSV, but that's a hassle, especially when you only need to discontinue 1 product.

Is there an extension/some solution that would let me create something like a macro that would change/modify all of these settings with a click from WITHIN Magento admin?

I would hoping attribute sets would do this, but this just controls which attributes show, now what they are set to.

I'm fairly certain many companies have needed solutions like this for efficiency/consistency. It would really suck to have to build it from scratch.

Thanks in advance for your help.


texts:
I am trying to translate and localize strings in the mini cart. It is not working doing it the standard way (csv in i18n).

It seems a different approach is used then standard strings in the code.
E.g.

<?= $block->escapeHtml(__('My text ')) ?>

See image.

How can this be translated?
Thank you for your input.


texts: Track customers who left an order at shipping/payment/final stage

texts: Want to track the customers who have put everything they wanted in the basket. Went to check out and changed their mind. Tried googling, but could not find anything related to this topic. How do I do this?


texts: How do I customize the steps of the progress bar on Magento 2 Checkout?

texts:
I would like to quite simply change the "shipping" step on the magento 2 checkout to read "delivery information".

I tried to do it through translation to no avail. I am wonder can anyone point me towards which template or xml needs to extended and edited to customize the steps' names please?


texts: How can i show tabs on frontend on custom product list page?

texts: I want to show these tabs on front end in custom product list page. On the click of these tabs the related content will show.


texts: Can we use magento luma theme for checkout

texts:
I'm Using magento 2 and Himarket theme. So the checkout page not working And I changed it to luma theme its work how can i fix the case

This is the error show in the console

[2017-12-17 10:00:26] [ERROR] Failed to load the "Magento_Tax/js/view/checkout/minicart/subtotal/totals" component.


texts:
I want to show logo as loader till the website is loading in the background how can I do in the latest manegto 2
Need help!


texts: How to setup multiple (isolated) Magento admin views (multi-vendor)

texts:
I am using magento 1.7. I want to use same Magento installation for multiple separate vendors.

I have set up multiple store views for the fronted (for each respective domain) but I have been unable to set up the Magento admin in the same fashion - where each domain administrator/vendor can add categories, products etc. only for his domain site


texts: Exception for escaping a character in search query/string

texts:
I need to add an exception to Magento's search to allow slashes / instead of escaping them to %252F - both in the search field and URL.

For example, a search for 'LIF-100/CC' currently gets converted to 'LIF-100%2FCC' (URL: /catalogsearch/result?q=LIF-100%252FCC), modifying the URL manually to '/catalogsearch/result?q=LIF-100/cc' gives the desired results.

I've got as far as the function getQueryText and am trying to figure out whether the following is what I'm after for this...

$this->_queryText = is_array($this->_queryText) ? ''
    : $stringHelper->cleanString(trim($this->_queryText));

I've tried various ways of removing the clean string / trimming from the above with no success (search query is always the same) so am wondering whether I should be looking at the function prepareResult instead?

Or should I be in fact searching for where the generation of the URL is formed?


texts: Magento 2: display numeric custom attribute as slider (just like price slider)

texts: I need to make a slider for my numeric custom attribute 'width'. Just like the price slider(in layered navigation) in the theme above.


texts: Changing catalog/product_list Block Template

texts:
I'm changing the <block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml"> template using another handler:

<other_custom_handler>
    <reference name="product_list">
        <action method="setTemplate">
            <template>custom/module/catalog/product/list.phtml</template>
        </action>
    </reference>
    <remove name="advancedmenu.sidenav" />
</other_custom_handler>

other_custom_handler is already a working handler, however, instead of copying catalog/product/list.phtml to custom module template, I want it to be more dynamic using the said method. It's not working.

Update:

Here are the layout handles:

array(7) {
  [0] => string(7) "default"
  [1] => string(8) "cms_page"
  [2] => string(17) "STORE_otherstore_default"
  [3] => string(28) "THEME_frontend_othertheme_default"
  [4] => string(15) "cms_index_index"
  [5] => string(21) "page_two_columns_left"
  [6] => string(19) "customer_logged_out"
}

I created a CMS page that displays all the products using catalog/product_list block. Products are displaying correctly, fyi.


texts: add products to magento 2 home page correctly?

texts: I'm trying to add the products to my home page, however when trying to add he simply adds the products normally but without customization, he adds with thema luma, how can I solve this?


texts: Multiple Duplicate Querys overloading Magento 2

texts:
We are currently experiencing an issue were our site runs fine for about 3 hours, but then our MySQL server crashes as a result of one query being run up to 300 times at once.
The query is the following.
SELECT COUNT(DISTINCT e.entity_id) FROM `catalog_product_entity` AS `e`
 INNER JOIN `catalog_category_product_index_store1` AS `cat_index` ON cat_index.product_id=e.entity_id AND cat_index.store_id=1 AND cat_index.category_id=10
 INNER JOIN `catalog_product_entity_int` AS `at_visibility_default` ON (`at_visibility_default`.`entity_id` = `e`.`entity_id`) AND (`at_visibility_default`.`attribute_id` = '99') AND `at_visibility_default`.`store_id` = 0
 LEFT JOIN `catalog_product_entity_int` AS `at_visibility` ON (`at_visibility`.`entity_id` = `e`.`entity_id`) AND (`at_visibility`.`attribute_id` = '99') AND (`at_visibility`.`store_id` = 1)
 INNER JOIN `catalog_product_entity_int` AS `at_status_default` ON (`at_status_default`.`entity_id` = `e`.`entity_id`) AND (`at_status_default`.`attribute_id` = '97') AND `at_status_default`.`store_id` = 0
 LEFT JOIN `catalog_product_entity_int` AS `at_status` ON (`at_status`.`entity_id` = `e`.`entity_id`) AND (`at_status`.`attribute_id` = '97') AND (`at_status`.`store_id` = 1) WHERE (IF(at_visibility.value_id > 0, at_visibility.value, at_visibility_default.value) = '4') AND (IF(at_status.value_id > 0, at_status.value, at_status_default.value) = '1')

The only variation is the category ID. Reindexing catalog_category_products does fix the issue for a short period, but eventually, the same problem persists.
Our MYSQL is running on an r4.x2large instance running MariaDB 10.2
Any help or feedback would be much appreciated.


texts: Dymanic Block based on Segments in phtml

texts:
I created 2 dynamic cms blocks in BE with different Customer Segment,
How can I call to them from phtml file?

Please note that dynamic cms block != cms block

tried

$block->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('block_identifier_cms_block')->toHtml();

But it works for static cms block


texts: Show customer name after setCustomerAsLoggedIn()

texts:
I'm experiencing terrible issue with M2 2.1.4.

I'm creating new user programmatically (without any issues) and then immediatelly I'm doing setCustomerAsLoggedIn():

/* Magento\Customer\Model\Customer $this->customer */
$loginCustomer = $this->customer->loadByEmail('johny@boy.com');
/* Magento\Customer\Model\Session $this->session */
$this->session->setCustomerAsLoggedIn($loginCustomer);
...
return $resultRedirect->setPath('customer/account');

But on the top (instead of "Sign In or Create Account") I can't see customer name. If I will log out and then log in - it will appear.
How to fix this problem and why this happening?

I check both modes (developer/production) and with cache/without cache.


texts:
I tested this with Paypal and Stripe in a Magento 2.3.5-p1.
If the order is in Authorise only it created the order correctly but the status never change because of something but does not show an error anywhere. If I put in Authorise and Capture it does not even complete the checkout, it gives an error and this appears in logs
Uncaught Error: Call to a member function getAdditionalInformation() on null in /var/www/webroot/ROOT/vendor/magento/module-sales/Model/OrderRepository.php:183

I tested in a clone environment and all works well.
Anyone had this problem? How can I solve it?
Thanks!


texts:
I'm using Magento 1.7.0.2 and have configured my store not to allow backorders, but for some reason some products are ordered having the stock at 0.

I'm using Paypal for the payment process.

Catalog -> Inventory Settings:

Decrease Stock When Order is Placed => Yes

Set Items' Status to be In Stock When Order is Cancelled => Yes
Display Out of Stock Products => Yes
Only X left Threshold => 0
Manage Stock => Yes
Backorders => No Backorders

Can someone please help me?


texts: Quote data is empty in multiple store views: Magento 2

texts:
I have a custom module that works with the default Magento quote factory. Here, I am fetching the quote data using the,

  \Magento\Quote\Model\QuoteFactory $quoteFactory

In my controller, I am trying to get the quote details using my quote id as below,

$quote = $this->quoteFactory->create()->load($quoteId);
        $subTotal = $quote['subtotal'];
        $total = $quote['grand_total'];

This is working as expected, however in case where magento is having multiple store views, the above is returning empty values.
The above code is working fine and the quote details are returning properly only in the Default Store View but not in other store views.

Note that the we are getting the quote id in all the store views but the quote is empty.

Is there anything else that I should do to get the quote details in other store views as well.

Please can anyone help?


texts: Overriding CustomerData/Cart.php removes Total from MiniCart Magento 2

texts:
I have overridden

  \vendor\magento\module-checkout\CustomerData\Cart.php

file in my custom plugin using di.xml using below code:

<preference for="Magento\Checkout\CustomerData\Cart"
                 type="Vendor\Package\CustomerData\Cart" />

It's working too. I can get SectionData defined in my custom Cart.php file in Minicart successfully.

but this removes Total from my Minicart which was working fine with default Cart.php.

Please suggest if i am doing something wrong in overriding file.


texts:
I get this error when I go to any page where there aren't any related products displayed.

Error:

( ! ) Fatal error: Uncaught Error: Call to a member function getRelatedProductCollection() on null in C:\wamp64\www\magento2\app\code\Test\RelatedProducts\Block\Product.php on line 88

Method where line 88 is located:

public function getRelatedProducts()
{
    $relatedProducts = $this
        ->getProduct()
        ->getRelatedProductCollection()
        ->addAttributeToSelect(['price','name','image','status']);

    return $relatedProducts;
}

Constructor:

public function __construct(
    StoreManagerInterface $storeManager,
    Currency $currency,
    Context $context,
    Registry $registry,
    array $data = []
) {
    $this->_storeManager = $storeManager;
    $this->_currency = $currency;
    $this->_registry = $registry;
    parent::__construct($context, $data);
}

EDIT:

If I add if($this->getProduct() != null) to getRelatedProducts() then everything is fine.

/**
 * Return current product
 *
 * @return mixed
 */
public function getProduct()
{
    return $this->_registry->registry('product');
}

/**
 * Return collection of related products from the current product
 *
 * @return mixed
 */
public function getRelatedProducts()
{
    if($this->getProduct() != null){
        $relatedProducts = $this
            ->getProduct()
            ->getRelatedProductCollection()
            ->addAttributeToSelect(['price','name','image','status']);

        $relatedProducts->getSelect()->orderRand();

        return $relatedProducts->getItems();
    }
}


texts: How to override the payment methods template while display in checkout page in magento 2

texts:
In Magento 1

/var/www/html/xxx/app/design/frontend/base/default/template/checkout/onepage/payment/methods.phtml.

In Magento 2

What is the equivalent file for the above one in magento 2 and how to override it. Please provide me  a solution


texts: Magento2: How to show recently added wishlist to be displayed at the starting In wishlist Page?

texts:
I want to show a recently added wishlist to be displayed at the starting In wishlist Page in magento2?
Any help would be appreciated.


texts:
There is a form post, it sends data without secure URL (HTTP):

<form id="answer_form_<?php echo $id;?>" class="form" method="post" action="<?php echo Mage::getUrl('productquestions/productquestions/saveanswers',array('product_questions_id'=>$id));?>">

How can I change it, so it posts with SSL (HTTPS) ?


texts:
I want to implement pricing per customer. I'm talking about tens of thousands of rules, and I'm considering adding every customer (5000+) to their own group, and uploading prices with a csv.
Other than really long reindexing times (which I have running on a cron schedule anyway), is there any good reason to not do it this way? This is built in Magento 2 functionality, so why are so many people using plugins that don't do as good a job?


texts: How to stop product images being displayed

texts:
I want to sell my services through a Magento store. I don't have any pictures of my services to add in store so in simple words. I just want to make an store without any product image.

Thanks.


texts: We use magmi to import images and other product details. We have a requirement right now where we need to upload a new image at position 1 for a lot of products. How can I achieve this using magmi?


texts: How to change the Products button URL on home page?

texts:
I originally asked this question on stackoverflow, but was scolded a bit and rated down.  I didn't realize there is now an entire Magento section, but now that I do this is clearly a more appropriate place to ask this question.

So, I know this is probably a simple question with an obvious answer... But my knowledge is pretty limited here. Anyway, all I'm trying to do is make the Product button I have in the top menu of my home page for my store link to a specific URL. So basically, right now, if you hover over the Products button you get a drop down of product categories (which is fine), but if you click on the actual Products button itself, it simply links back to the homepage. I'd like to link it to a Products landing page that I've created instead.

How do I achieve this? For reference, my site is: http://www.soundcherry.com.

The code that I THINK I need to edit is here: public_html/app/design/frontend/default/(the template I'm using)/template/catalog/navigation/top.phtml

And the code looks like:

<?php $_menu = $this->renderCategoriesMenuHtml(0,'level-top') ?>

<a href="<?php echo $this->getUrl() ?>"><?php echo $this->__('Home') ?>

<a href="<?php echo $this->getUrl('') ?>"><?php echo $this->__('') ?>
<?php if($_menu): ?>

        <?php echo $_menu ?>

<?php endif ?>

<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('menu')->toHtml(); ?>

I'm not sure what to change, though.  Or, even if this is the correct code to edit.  Any help will be greatly appreciated!


texts:
I want to add a column to the sales_flat_quote_item (and ..._order_item) table through an install script, but when I go to the table sales_flat_quote_item (or ..._order_item) in my database - the column is not there.

The install script's version is 0.0.1. My config.xml is also 0.0.1.

I have cleared the cache. I refreshed the back-end, so the script has ran.

Any clues?

$installer = $this;
$installer->startSetup();
$installer->getConnection()->addColumn($installer->getTable('sales/quote_item'), 'print_sku', "varchar NOT NULL");
$installer->getConnection()->addColumn($installer->getTable('sales/order_item'), 'print_sku', "varchar NOT NULL");
$installer->endSetup();


texts: Magento2 controllers: Method executeInternal

texts:
I just pulled a fresh copy of Magento 2 (1.0.0-beta5) and the extensions that I've worked on don't work anymore.
That doesn't surprise me. It usually happens like that. But this time is different.

I got this error:

  PHP Fatal error:  Class
  [Namespace][Module]\Controller\Adminhtml\Module\Validate contains 1
  abstract method and must therefore be declared abstract or implement
  the remaining methods
  (Magento\Framework\App\Action\Action::executeInternal) in
  app/code/[Namespace][Module]/Controller/Adminhtml/Module/Validate.php
  on line 30

The error message is straight forward. I need to implement an abstract method.
What I don't get is, what does this method executeInternal supposed to do.
I have a hunch is a replacement for the old execute method that is what gets executed for a controller action.
But I see that method execute is still there and now requires a \Magento\Framework\App\RequestInterface parameter.
Can someone explain what executeInternal does and what does execute do now?


texts: How to override addAddressByType() in class Magento\Framework\Mail\Template\TransportBuilder as it is a private function?

texts:
I tried to override addAddressByType() function in Magento\Framework\Mail\Template\TransportBuilder but I can't override this function only as it is a private function.

Then I tried to override whole class but getting the below error.

1 exception(s):
Exception #0 (Magento\Framework\Exception\RuntimeException): Type Error occurred when creating object: Magento\Customer\Model\Customer\Interceptor

Exception #0 (Magento\Framework\Exception\RuntimeException): Type Error occurred when creating object: Magento\Customer\Model\Customer\Interceptor
<pre>#1 Magento\Framework\ObjectManager\Factory\Compiled->create('Magento\Customer...') called at [vendor/magento/framework/ObjectManager/Factory/Compiled.php:150]
#2 Magento\Framework\ObjectManager\Factory\Compiled->get('Magento\Customer...') called at [vendor/magento/framework/ObjectManager/Factory/Compiled.php:79]
#3 Magento\Framework\ObjectManager\Factory\Compiled->create('Magento\Customer...') called at [vendor/magento/framework/ObjectManager/Factory/Compiled.php:150]
#4 Magento\Framework\ObjectManager\Factory\Compiled->get('Magento\Customer...') called at [vendor/magento/framework/ObjectManager/Factory/Compiled.php:79]
#5 Magento\Framework\ObjectManager\Factory\Compiled->create('Magento\Weee\Mod...') called at [vendor/magento/framework/ObjectManager/Factory/Compiled.php:150]
#6 Magento\Framework\ObjectManager\Factory\Compiled->get('Magento\Weee\Mod...') called at [vendor/magento/framework/ObjectManager/Factory/Compiled.php:79]
#7 Magento\Framework\ObjectManager\Factory\Compiled->create('Magento\Weee\Mod...') called at [vendor/magento/framework/ObjectManager/ObjectManager.php:70]
#8 Magento\Framework\ObjectManager\ObjectManager->get('Magento\Weee\Mod...') called at [vendor/magento/framework/Interception/PluginList/PluginList.php:250]
#9 Magento\Framework\Interception\PluginList\PluginList->getPlugin('Ranosys\Subscrib...', 'weee-app-action-...') called at [vendor/magento/framework/Interception/Interceptor.php:119]

Please help to share your suggestions if there is any other better approach.


texts:
I'm trying to use this code I found here Get Shopping cart rule coupon code
 (with alittle modifications) to get shopping cart rules:

<?php
$current_sku = $_product->getSku();
$rules       = Mage::getResourceModel('salesrule/rule_collection')->load();
foreach ($rules as $rule) {
    if ($rule->getIsActive()) {
        $rule = Mage::getModel('salesrule/rule')->load($rule->getId());
        $conditions = $rule->getConditions()->asArray();
        foreach( $conditions['conditions'] as $_conditions ):
            foreach( $_conditions['conditions'] as $_condition ):
                $string = explode(',', $_condition['value']);
                for ($i=0; $i<count($string); $i++) {
                    $sku = trim($string[$i]); ?>
<?php if ($sku === $current_sku): ?>

<img src="<?php echo $this->getSkinUrl('images/free-gift.png',array('_secure'=>true)) ?>" style="max-width:140px;width:100%;height:auto;max-height:140px;position:relative;bottom:60px;left:10px" />

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

I'm using it on the Product Details page. The code works but I'm getting the following error on line 83 i.e.  $conditions = $rule->getConditions()->asArray();

Warning: Invalid argument supplied for foreach()

It seems after searching Google I need to somehow check if the Array() has a value but I'm not sure how. Or maybe it suppose to always have a value?

Any help would be great.


texts: magento back to cart after filling the delivery information

texts:
I am fixing a magento 1.9 site, earlier it was working but from 2 days it keep redirecting to cart page after filling the delivery option when next is clicked, it redirect to the cart page. i have enabled the error from index the php and on console i found the issue with savebilling method as shown below

 VM1688 b67a30ef8ededbc5bc2a1db8ac5699fd.js:1530
   POST
   https://example.com/checkout/onepage/saveBilling/ 500 (Internal Server Error)
    request @ VM1688 b67a30ef8ededbc5bc2a1db8ac5699fd.js:1530
    initialize @ VM1688 b67a30ef8ededbc5bc2a1db8ac5699fd.js:1495
    (anonymous) @ VM1688 b67a30ef8ededbc5bc2a1db8ac5699fd.js:429
    klass @ VM1688 b67a30ef8ededbc5bc2a1db8ac5699fd.js:101
    save @ VM1702 opcheckout.js:372
    phonevalidation @ (index):1067
    onclick @ (index):999
    Navigated to https://example.com/checkout/cart/

Can anyone suggest the possible cause for this issue. I have spent many hours on this. Many answers suggest to handle null, but i think it has to do with some security updates done on  server as it was working previously..


texts: How to change configurable product "Add to Cart" button label to something else in the category page

texts:
I am building a custom theme

I need to change the configurable products "Add to Cart" button label to "See Options" in category page.

Only for the configurable product.

Any Help will Appreciate!!


texts: How to set a payment method as a default payment method only magento 2 backend?

texts: I'm doing a module exercise in magento 2. How can I set a payment method as payment method default in mangento 2? Ex:


texts: Check what Magento patches were installed

texts:
I need to install patches 5994 and 6285 on Magento installation (Community edition) but I am not sure if they are already installed or not.

Is there any way in Magento to check if a particular patch is already installed or not?


texts: display all customers using console command magento2.2.3

texts: How to display registered customers in terminal using custom console command?Can anyone please help me out.


texts: The use of function pathinfo() is discouraged Magento 2

texts:
I am checking uploaded file extension by pathinfo() function of php but in coding standard check it's shows

  The use of function pathinfo() is discouraged

My code:

$fileExt = pathinfo($file, PATHINFO_EXTENSION);


texts: Custom layout .xml in child-theme works locally, but not on the server

texts:
I have a strange problem. In our custom child-theme we have some simple layout files, for example removing the wishlist links and sidebar or moving page title, category image, etc into the content container. This example file is located at app/design/frontend/MYCOMPANY/MYTHEME/Magento_Catalog/layout/catalog_category_view.xml

and it contains the following:

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

<body>
    <!-- move the title, category descr., category image and cms block into the content container -->
    <referenceContainer name="content">
        <block class="Magento\Theme\Block\Html\Title" name="page.main.title" template="Magento_Theme::html/title.phtml" />
        <block class="Magento\Catalog\Block\Category\View" name="category.image" template="Magento_Catalog::category/image.phtml" />
        <block class="Magento\Catalog\Block\Category\View" name="category.description" template="Magento_Catalog::category/description.phtml" />
        <block class="Magento\Catalog\Block\Category\View" name="category.cms" template="Magento_Catalog::category/cms.phtml" />
    </referenceContainer>

</body>

This works locally without any problems.

However, on the server this does not work.

Can anyone think of any reason as to why? Our local docker container is the same php, apache etc version as on the server.

Follow-up edit:

After various scenarios and testing on a fresh install, we managed to pinpoint this issue to something in our database. Exactly what setting caused it is unclear for now. I'll update it if I find the setting.


texts: How can we write the below code in magento 2.2.5?

texts:
How can we write the below code lines in Magento 2.2.5 controller and model?

$order = Mage::getModel('sales/order')
            ->getCollection()
            ->addFieldToFilter('quote_id', $quote->getId())
            ->getFirstItem();


texts: What renders the gallery images? Gallery returns thumbnail versions

texts:
I'm currently making a M2 site and I'm fairly new to the platform. I'm trying to make it so that people can customize their product. I found this extension: https://github.com/develodesign/magento2-productdesignr

It works perfectly! However, the gallery images turn into thumbnail size for some reason when I enable it. I'm wondering, what magento 2 function controls how the images are shown in the gallery? Maybe I can start debugging if I knew where to look. I've attached 2 pictures, one that currently shows the thumbnail size when the extension is enabled and the 2nd one shows the normal use case.


texts: How to display values of $data in saveAction() before saving the action

texts:
I've created an Adminhtml extension with a form and in the controller I have the saveAction(). I need to debug it and I need to see the values of $data, but var_dump($data); doesn't work, it just returns the success or error message.

This is the code that I have in my saveAction within the controller:

public function saveAction() {
        if ( $data = $this->getRequest()->getPost() ) {
            $this->_getSession()->setFormData( $data );
            $model = Mage::getModel( 'namespace_module/table' );
            $id    = $this->getRequest()->getParam( 'entity_id' );

            try {
                if ( $id ) {
                    $model->load( $id );
                }
                // TODO: filter out attributes we don't want to allow changes to
                $model->addData( $data )->save();

                $this->_getSession()
                     ->addSuccess( $this->__( 'Result was successfully saved' ) );
                $this->_getSession()->unsFormData();

                if ( $this->getRequest()->getParam( 'back' ) ) {
                    $params = array( 'id' => $model->getId() );
                    $this->_redirect( '*/*/edit', $params );
                } else {
                    $this->_redirect( '*/*/list' );
                }
            } catch ( Exception $e ) {
                $this->_getSession()->addError( $e->getMessage() );
                if ( $model->getId() ) {
                    $this->_redirect( '*/*/edit', array( 'id' => $model->getId() ) );
                } else {
                    $this->_redirect( '*/*/new' );
                }
            }

            return;
        }

        $this->_getSession()->addError( $this->__( 'No data found to save' ) );
        $this->_redirect( '*/*' );
    }

Could you guys help me with this?

Thanks.


texts: Magento2 - how to show custom menu in top menu?

texts:
I need to show only first level categories and their products on top menu to replace Magento's default top menu.
For example categories and products should display like:

Tshirts    Polo Tshirts  Price:$10.00    Polo Tshirts Green  Price:$10.00   Polo Tshirts Yellow Price:$10.00
Shirts    Polo shirts  Price:$10.00   Polo Tshirts Green  Price:$10.00    Polo Tshirts Yellow Price:$10.00

How to get the product collection in topmenu blocks?


texts: Magento 2: Static files are present but shows 404

texts:
I installed Magento 2 in my local environment and executed each command:

php bin/magento cache:clean
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy

But when I hit the site from browser, it shows following errors:
http://127.0.0.1/m2shop.drberg.com/pub/static/version1513076694/frontend/Magento/luma/en_US/css/styles-l.css net::ERR_ABORTED
(index):16

http://127.0.0.1/m2shop.drberg.com/pub/static/version1513076694/_cache/merged/9de8797d0c615276fc794278a0af8df2.css net::ERR_ABORTED
(index):21

http://127.0.0.1/m2shop.drberg.com/pub/static/version1513076694/_cache/merged/c0b5661e7cfc4d3e29c8fc8495e4d56e.js net::ERR_ABORTED
(index):144

Uncaught TypeError: require.config is not a function
    at (index):144
(anonymous) @ (index):144
(index):243

http://127.0.0.1/m2shop.drberg.com/pub/static/version1513076694/frontend/Magento/luma/en_US/images/logo.svg 404 (Not Found)
(index):18

http://127.0.0.1/m2shop.drberg.com/pub/static/version1513076694/frontend/Magento/luma/en_US/css/print.css net::ERR_ABORTED

All these files are actually present in the directory but Magento is not unable to read those files. why?


texts:
I implemented apple pay in my magento store I create button and now i want onvalidatemerchant but when I call end point I'm getting this error

  ssl3_read_bytes:tlsv1 alert unkown ca.

I am implementing apple pay in Magento so far I have implement this code


texts: Magento add new Button on Sales order view

texts:
I want to add new Button on Sales order view page. I created below mention code

observer file

<?php

class Ar_Orderstatus_Model_Observer
{

    public function addOrderstatusAction($observer)
    {
        $block = $observer->getEvent()->getBlock();
        if ($block instanceof Mage_Adminhtml_Block_Sales_Order_View) {
            $message = Mage::helper('sales')->__('Are you sure you want to Change Status?');

            $block->addButton('rto',
                array( 'label' => Mage::helper('sales')->__('RTO'),
                    'onclick' => "confirmSetLocation('{$message}', '{$block->getUrl('orderstatus/adminhtml_index/rto')}')", 'class' => 'go' ));

           $block->addButton('in_shipment',
            array( 'label' => Mage::helper('sales')->__('In Shipement'),
                'onclick' => "confirmSetLocation('{$message}', '{$block->getUrl('orderstatus/adminhtml_index/in_shipment')}')", 'class' => 'go' ));
        }
    }
}

controller file

<?php

class Ar_Orderstatus_Adminhtml_IndexController extends Mage_Adminhtml_Controller_Action
{
    protected function _initOrder()
    {
        $id = $this->getRequest()->getParam('order_id');
        $order = Mage::getModel('sales/order')->load($id);

        if (!$order->getId()) {
            $this->_getSession()->addError($this->__('This order no longer exists.'));
            $this->_redirect('*/*/');
            $this->setFlag('', self::FLAG_NO_DISPATCH, true);
            return false;
        }
        Mage::register('sales_order', $order);
        Mage::register('current_order', $order);
        return $order;
    }

public function testAction()
{
    if ($order = $this->_initOrder()) {
        try {
            $order->setState('rto', true)
                ->save();
            $this->_getSession()->addSuccess(
                $this->__('The order state has been changed.')
            );
        }
        catch (Mage_Core_Exception $e) {
            $this->_getSession()->addError($e->getMessage());
        }
        catch (Exception $e) {
            $this->_getSession()->addError($this->__('The order state has not been changed.'));
            Mage::logException($e);
        }
        $this->_redirect('adminhtml/sales_order/view', array('order_id' => $order->getId()));
    }

}

}


texts: Get error : Ajax is not defined when install new theme in Magento2

texts:
My custom grid in front end using ui_component worked fine before I install new theme. I'm getting this error in console log:

Please help me!


texts: What is the difference between the image and media directories in a theme?

texts:
When looking through Magento 2 themes, the directory structure include the directories images and media.  It seems like image files (png, gif, etc) could go into either directory.

What are the differences between each directory and what types of files should go into each?


texts: How to pass dynamic values into an array

texts:
I'm creating a list of products, which is filtered to only show products within certain categories in Magento. I'm using the AddAttributeToFilter which is working fine:

$products->addAttributeToFilter('category_id', array('in' => array(105,106)));

This seems to work fine and it retrieves products that are in category 105 and 106.

However, I'm building a form that will dynamically pass the IDs into the filter depending on a user's selection. So in some case there will only be 2 category IDs, other times there maybe 6 different category IDs.

For example:

$products->addAttributeToFilter('category_id', array('in' => array(105,106,124,158,147)));

However, I can't figure out how I can create the array dynamically.

I tried this but it doesn't work:

$val = "105,106,124,158,147";
$products->addAttributeToFilter('category_id', array('in' => array('$val')));

Any help would be much appreciated.


texts: getLastRealOrderId() always return null for custom payment methods on 2.4.2

texts:
I had a custom payment module that was working properly on 2.2.x as well as 2.3.x. However, when I tried to install it onto a clean 2.4.2 instance, I found that the function getLastSuccessQuoteId() called on the checkout session always gave me a null result.
The payment gateway I implemented is more or less like the PayPal Hosted Solution, where the customers would be redirected to a 3rd party platform for the settlement, and redirected back to the shop afterward via a return URL.
On 2.2.x and 2.3.x, I was able to get the previous success quote ID by calling getLastSuccessQuoteId() in this return URL, but now it gave me nothing.
I am not sure which part of the new Magento was contributing to the difference here. I have tried the following directions:

add the CSP whitelist
switch on the CSP report-only mode in the config.xml
disable the CSP module
implement those new CsrfAwareActionInterface, HttpPostActionInterface, HttpGetActionInterface for the return action controller

In the end, I have even tried to rewrite the module completely based on the PayPal Hosted solution, but I am still getting the same result.
I really have no clue what I could have missed out on.


texts:
Some months ago i have patched my magento with:

SUPEE-1533
SUPEE-5344
SUPEE-6285
SUPEE-5994
SUPEE-6482
SUPEE-6788

and i patched using this instruction https://magentary.com/kb/install-supee-6788-without-ssh/ for all the patch.
After that i checked with this https://magento.com/security-patch and everithing was ok.

Last week i found inside System->Configuration->General->Design->Html Head->Miscellaneous Scripts a javascript code that was very very strange and i deleted it

In your opinion there is something else i have to check like core files etc...?

Thank you for your suggestion


texts: Cron.php not working and no "Cron (Scheduled Tasks)" configuration block

texts: I've a magento 1.6 instance that doesn't trigger cron jobs when cron.php is hit. It also doesn't have a Cron (Scheduled Tasks) configuration section under Admin > System > Configuration > System. Mage_Cron is enabled. I've no idea why it isn't working. Any feedback would be helpful. Thanks!


texts: Combining Simple products and nominal subscriptions

texts: My site at http://www.avantalarm.com/ is trying to sell a simple product (or bundled product) in a security system and we also offer monitoring agreements that require monthly billing and affect the price we offer our customers.  I've added all of our monitoring options as nominal products and included them as an option to add to a security system package.  When I proceed to checkout, it says that I'm unable to go to checkout with a nominal and simple product at the same time.  I'm curious if there is a work around as it is an important aspect to our website.  Any help would be appreciated.  Let me know if I can clarify my question with code as I'm new to StackExchange and new to Magento.


texts:
I haven't had any problems but I moved to a new server and really haven't check it out for a while but now when I try to add a product to google shopping I get the following error:

Recoverable Error: Object of class Mage_Catalog_Model_Resource_Eav_Attribute could not be converted to string in /home/xxxxxxx/public_html/app/code/community/BlueVisionTec/GoogleShoppingApi/Model/Attribute/GoogleProductCategory.php on line 30

Here is the code the error is pointing to:

    public function convertAttribute($product, $shoppingProduct)
    {
        // get category from product attribute
  -- line 30 here -->   Mage::log(__LINE__.$product->getResource()->getAttribute('google_shopping_category'));
        $value = $product->getResource()->getAttribute('google_shopping_category')
        ->getFrontend()->getValue($product);
        $value = preg_replace('/\d+ /','',$value);
        $shoppingProduct->setGoogleProductCategory($value);

        return $shoppingProduct;
    }

I've tried many things (mostly guesses) searched on Google and still can't seem to fix this error. Any help would be very much appreciated.


texts: Admin controller is not being called in Magento Ajax

texts:
I am calling admin controller via ajax, but it is not being called.
Here is the controller file-

Assel/Allstock/controllers/Adminhtml/AllstockController

<?php
class Assel_Allstock_Adminhtml_AllstockController extends Mage_Adminhtml_Controller_Action
{
  protected function _isAllowed()
  {
    return true;
  }

  protected function _initAction() {
        $this->loadLayout()
            ->_setActiveMenu('Purchase')
            ->_addBreadcrumb(Mage::helper('adminhtml')->__('Allstock'), Mage::helper('adminhtml')->__('Allstock'));

        return $this;
  }

  public function indexAction() {
        $this->_initAction()
             ->_addContent($this->getLayout()->createBlock('allstock/adminhtml_allstock'))
            ->renderLayout();
  }

  public function productStockAction()
  {
      return "hello";
  }

  // Used for AJAX loading
   public function gridAction()
   {
        $this->loadLayout();
        $this->getResponse()->setBody(
            $this->getLayout()->createBlock('allstock/adminhtml_allstock_grid')->toHtml()
        );
   }
}
?>

Here is my config.xml-

 <?xml version="1.0" encoding="UTF-8"?>
<config>
  <modules>
        <Assel_Allstock>
            <version>1.0.0</version>
        </Assel_Allstock>
   </modules>
   <admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <assel_allstock after="Mage_Adminhtml">Assel_Allstock_Adminhtml</assel_allstock>
                    </modules>
                </args>
           </adminhtml>
        </routers>
    </admin>
   <global>
      <helpers>
            <allstock>
                <class>Assel_Allstock_Helper</class>
            </allstock>
        </helpers>
        <blocks>
            <allstock>
                <class>Assel_Allstock_Block</class>
            </allstock>
        </blocks>
   </global>
    <adminhtml>
        <layout>
            <updates>
                <assel_allstock>
                    <file>assel/allstock.xml</file>
                </allstock>
            </updates>
        </layout>
    </adminhtml>
</config>

Here is the template file --

adminhtml/base/default/template/assel/allstock.phtml

 <script>
        var url= "<?php echo $this->getUrl('allstock/adminhtml_allstock/productStock/'); ?>";
        $j('#product_search').keyup(function() {
          delay(function(){
            new Ajax.Request(url, {
                  method: 'get',
                  onSuccess: function(response){debugger
                  },
                  onFailure:  function(response) {debugger
                    Element.hide('loading-mask');
                    alert("An error has been occured during Ajax call, please try again");
                  },
            });
          }, 2000 );
        });
        var delay = (function(){
          var timer = 0;
          return function(callback, ms){
          clearTimeout (timer);
          timer = setTimeout(callback, ms);
         };
        })();
    </script>

I am getting this value in url variable in ajax-

"http://example.com/index.php/admin/allstock/productStock/key/NuEkv9QcEXoP4NWr/?isAjax=true"

I am getting 404 error in ajax call. Not sure why I am getting this. Can anyone help me into this.


texts: Magento 2 customer_register_success not working

texts:
I want to get customer id after new customer register successfully in Magento 2.2.2.
In app/code/vendor/module/etc/frontend/events.xml-> I added this code

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <event name="customer_register_success">
        <observer name="update_customer_referal_code" instance="vendor\module\Observer\UpdateCustomerMeta" />
    </event>
</config>

and in app/code/vendor/module/Observer/UpdateCustomerMeta.php -> I have added this

<?php

namespace vendor\module\Observer;

use Magento\Framework\Event\ObserverInterface;

class UpdateCustomerMeta implements ObserverInterface
{

    protected $_customerRepositoryInterface;

    public function __construct(
        \Magento\Customer\Api\CustomerRepositoryInterface $customerRepositoryInterface
    ) {
        $this->_customerRepositoryInterface = $customerRepositoryInterface;
    }

    public function execute(\Magento\Framework\Event\Observer $observer)
    {
        $customer = $observer->getEvent()->getCustomer();
        print_r($customer->getId());
        echo "if this string shows it means observer works";
        exit();
    }
}

but when I register a user it directly goes to customer panel after registering anyone please tell what mistake I am making.


texts: Configurable And Simple Products Imported But Not Associated

texts:
My import works with no errors, my configurable product has all of the simple products' SKUs in the associated product sku field.

The products are all added, but the simple products do not appear in the configurable product.

I am trying to do something like this in configurable_variations field:

sku=shirt-black,color=Black,style=Medium|sku=shirt-red,color=Red,style=Medium


texts: M2 Get Customer Group Price on Category Page

texts:
I seem to be unable to get the current customer group price for a product.

Product is set up with a standard price of £20 and a 'wholesale' group price for 1+ units at £10.

On a category page (when logged in as a wholesale customer), I correctly see the struck through price and £10 beside it.

However, I want to show an icon when a customer is getting a special price because of their group.

$product->getPrice() returns 20, $product->getFinalPrice() returns 20, $product->getSpecialPrice() is null.

I'm trying to get the current group customer price (10) in a variable, so I can compare it. Is this possible? If so, what function do I need to use?


texts: "Invalid Form Key. Please refresh the page" on Admin login page. I set the wrong cookie domain in the Admin panel. How to change that in the database?

texts:
Magento 1.9.4

I am setting up a new Magento 1.9.4 store but I am setting that up for an existing live store which is currently running Magento 1.9.1.

I made the mistake of entering the other domain into the cookie domain setting in the Admin panel and it won't let me login into the Admin panel. I get the following  Error:

Invalid Form Key. Please refresh the page.

I deleted browser and Magento Cache (via FTP) and tried a different browser. I get the same Error. I need to find the table in the database to change the cookie domain there but I am not sure where to look? I am in phpMyAdmin.

I found core_config_data but I don't see it there.


texts: Having issue loading frontend on Magento 2.3

texts:
I am running Magento2.3 on AWS m5.xlarge (ubuntu 18.04)
Backend is running pretty smooth, with page refreshes within 2-3 seconds, but frontend most of the time doesn't load and when it loads it takes around 3-5 minutes.
One thing I noticed is mysql taking high cpu usage around 250% (when ran top command) and overall 95% cpu.
I ran sqltuner command and did the necessary optimization as suggested by the command.
I checked by logging in mysql and ran
show full processlist;

but it only shows the above command.
Not sure what I'm missing. Any help would be appreciated.


texts:
I've got a client running a custom theme. I'm trying to edit the checkout field titles / descriptions:

app/design/frontend/theme/default/template/checkout/onepage/billing.phtml

The changes I make here are not reflecting on the frontend, even with all caches flushed & disabled. I've even gone as far as disabling the file, (billing.phtml.disabled) and directly modifying the base theme to test:

app/design/frontend/base/default/template/checkout/onepage/billing.phtml

  Please note that modifying the core file was purely for testing purposes & not recommended under any other circumstances

None of these changes are being reflected on the frontend. I feel like I must be missing something.

Any ideas?


texts: How to fix Invalid method Varien_Object::save() in product saving?

texts:
I got following error when tried to save product from collection:

  Invalid method Varien_Object::save(Array())

And here is full code (I know, that it is ugly, but now I try refactor it):

public function postAction()
{
    $sku = Mage::app()->getRequest()->getParam('sku');
    $file = Mage::app()->getRequest()->getParam('file');

    if (empty($sku) or empty($file)) {
        echo "FALSE";
        return;
    }

    $path = Mage::getBaseDir() . "/media/photosimport/";
    $filepath = $path . $file;
    $img_save_mode = array('image', 'small_image', 'thumbnail');

    $product = Mage::getModel('catalog/product')->loadByAttribute('sku', $sku);
    if (!$product->getId()) {
        echo "FALSE";
        return;
    }

    Mage::log($sku . ' =>' . $product->getName(), null, 'photosimport.log');

    $filename = pathinfo($file, PATHINFO_FILENAME);
    $filenameArray = explode("_",$filename); //0 - SKU, 1 - image name
    $imagename = (isset($filenameArray[1]) && !empty($filenameArray[1])) ? $filenameArray[1] : null;
    $prod = Mage::getModel('catalog/product')->load($product->getId());
    $galleryData = $prod->getData('media_gallery');

    foreach ($galleryData['images'] as $galleryImage)
    {
        $gf = explode("/", $galleryImage['file']);
        if ($gf[count($gf) - 1] == $file) {
            echo "UPDATE";
            unlink(Mage::getBaseDir() . '/media/catalog/product' . $galleryImage['file']);
            rename($filepath, Mage::getBaseDir() . '/media/catalog/product' . $galleryImage['file']);
            @unlink($filepath);
        }
    }
    if (file_exists($filepath)) {
        try {
            if (empty($imagename)) {
                $product->addImageToMediaGallery($filepath, $img_save_mode, true, false);
            } else {
                $product->addImageToMediaGallery($filepath, false, true, false);
            }
            Mage::log($sku . ' ok', null, 'photosimport.log');
        } catch (Exception $e) {
            Mage::log('error: ' . $e->getMessage(), null, 'photosimport.log');
            echo "FALSE";
            echo $e->getMessage();
            return;
        }
    } else {
        Mage::log(
            'Product does not have an image or the path is incorrect. Path was: '.$filepath,
            null,
            'photosimport.log'
        );
        echo "FALSE";
        return;
    }

    try {
        $product->save();
    } catch (Exception $e) {
       echo $e->getMessage();
    }

    @unlink($filepath);
    echo "OK";
}

Please, help me to fix that! I tried to use saveAttribute via resource model, but it didn't work too.


texts:
I am using Magento 1.9.3.6 version.

I need form values in the controller which is other than form action. So I serialized the form values and set into the Magento Core session like below. When I print the Session Value it is returns empty or the variable name as value.

var samples = JSON.stringify(jQuery('#sell-add-product').serializeArray());
var a = "<?php echo Mage::getSingleton('core/session')->setMyValue("+samples+");?>";

I am getting like below in the controller:

 $data = Mage::getSingleton('core/session')->getMyValue();
 print_r($data);

Out put is +samples+


texts:
I have a Sign in Link that successfully changes to sign out when a user is logged in, and successfully logs the user out when I click sign out. However, I ran into a bug. When Signed in, if I go to any other page or link, The Sign out link changes back to Sign in, Yet I show i am still signed in on the user dashboard.
Here is the code in my phtml file that switches the Sign in to Sign out.

<?php

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$customerSession = $objectManager->get('Magento\Customer\Model\Session');
if($customerSession->isLoggedIn()) {
?>  <a href="<?php echo $this->getUrl("customer/account/logout");?>"><?php echo __("Sign Out");
} else {
?>  <a href="<?php echo $this->getUrl("customer/account/login");?>"><?php echo __("Sign
In/Register");?>
<?php }
?>

Also, When clicking the hamburger menu to the right of the log out link when signed in, The hamburger menu logs me out. Here is the code for the menu button.
<button class="hamburger"><?php echo __("☰")?></button> <button class="cross">˟</button>

I am trying to get the logout button to stay visible no matter what page i visit after being signed in. There must be something i am not seeing here.


texts: Magento 1.9 Caching Skin Files (CSS and JS)

texts:
Is there anyway to force client side cache.  We would like customers to receive the latest updates made to CSS and JS files without them having to hard cache or clear their browser cache.

We have tried flushing all cache options in the administrative backend udner system -> cache management

We have tried merging the CSS and JS files under system -> advanced -> developer -> CSS/JS settings

We have tried deleting these merge files in media/css_secure in combination with merging and un merging the files as outlined above.

Please advise best practice for releasing the updated files for Magento 1.9


texts: addFieldToFilter() not considering associated products

texts:
I'm using below code to get product collection,

$products = Mage::getResourceModel('catalog/product_collection')
                  ->AddAttributeToSelect('name')
                  ->addAttributeToSelect('price')
                  ->addAttributeToSelect('small_image')
                  ->addAttributeToSelect('image')
                  ->addFieldToFilter('size', array('eq' => '40'))
                  ->AddCategoryFilter($category);

Using ->addFieldToFilter('size', array('eq' => '130')) i'm trying to filter product collection by it's size.

As a result i'm getting empty result coz, my configurable product don't have attribute size

I've tried to include child product collection by

->joinTable('catalog/product_relation', 'child_id=entity_id', array(
                            'parent_id' => 'parent_id'
                    ), null, 'left')

but not working, did anyone know how to consider associated products while filtering ?


texts: How to access data in block which is passed from controller

texts:
I have a controller and I have created block using createBlock method in controller and have passed a userid to it

  $block =  $this->_pageFactory->create();

  $block->getLayout()
  ->createBlock('Magecomp\Crud\Block\GetUserById','magecompcrud.edituser',['data'=>['userid'=>$userid]]);

Now how can I access this userid in blcok or blcok method