texts:
I'm searching on the internet for an answer but no luck so far.

I have 2 Magento 2 webshops. One is version 2.2.7 and one is 2.3.1.
Both have the latest Porto theme installed and both work with the child theme.

With both webshops I did some product imports and when you try to search for a product you get this error:

Column not found: 1054 Unknown column 'search_result.score' in 'order clause'.
query was:

SELECT `e`.*,
`stock_status_index`.`stock_status` AS `is_salable`,
    `price_index`.`price`, `price_index`.`tax_class_id`,
    `price_index`.`final_price`,
    IF(price_index.tier_price IS NOT NULL, LEAST(price_index.min_price, price_index.tier_price), price_index.min_price) AS `minimal_price`,
    `price_index`.`min_price`,
    `price_index`.`max_price`,
    `price_index`.`tier_price`,
    `cat_index`.`position` AS `cat_index_position`
    FROM `catalog_product_entity` AS `e`
    INNER JOIN `cataloginventory_stock_status` AS `stock_status_index` ON e.entity_id = stock_status_index.product_id
    AND stock_status_index.website_id = 0
    AND stock_status_index.stock_id = 1
    INNER JOIN `catalog_product_index_price` AS `price_index` ON price_index.entity_id = e.entity_id
    AND price_index.website_id = '1'
    AND price_index.customer_group_id = 0
    INNER JOIN `catalog_category_product_index_store1` AS `cat_index` ON cat_index.product_id=e.entity_id
    AND cat_index.store_id='1'
    AND cat_index.visibility IN(3, 4)
    AND cat_index.category_id='3'
    WHERE (stock_status_index.stock_status = 1)
    ORDER BY `search_result`.`score` desc LIMIT 9

The only time I saw someone with this issue was in another question:
magento2 search_tmp join leads to empty results in category listing from Gabriel but no answer so far.

What is it that is causing this?

Cheers,

Steve


texts: Magento 2 pub/static/_cache/merged files are not created

texts:
Magento version 2.1.9

Trying to deploy the website results in strange JS and CSS errors.

With the configuration of:

dev/js/merge_files = 0
dev/js/enable_js_bundling = 0
dev/js/minify_files = 0
dev/css/merge_css_files = 0
dev/css/minify_files = 0

Results in a pub static folder without minified/bundled files (without a _cache folder in the pub static), which is supposed to work fine. However, Magento is still looking for a bundled JS file (404 error in the console looking for a JS file in the pub/static/_cache/merged folder)

With this configuration:

dev/js/merge_files = 1
dev/js/enable_js_bundling = 1
dev/js/minify_files = 1
dev/css/merge_css_files = 1
dev/css/minify_files = 1

There should be a folder + file be created in /pub/static/_cache/merged, but these arent created.

All permissions are set properly and no errors are being logged.


texts:
I have recently upgraded the Magento from 1.6.2 to 1.9.2 and I found the cart page is too slow. Not only when I add product to cart ,but also when i just load the cart page . I did confirm that the site is using the default cartcontroller .
Here is the profiler report.

mage::dispatch::routers_match                           2.636556    1   0   0.00 KB
mage::dispatch::controller::action::checkout_cart_index 2.516693    1   0   0.00 KB
Mage_Checkout_CartController::indexActioncart_display   0.560941

I also did check with the innodb_buffer_pool_size  and its also setup correctly as per the requirement.

Can anyone help me to figure out the speed issue on cart page? All other pages are running smooth compare to this cart page.


texts:
I want to show uploaded image in admin form. I use this code to upload image in admin form.

$fieldset->addField(
    'image',
    'image',
    [
        'name' => 'image',
        'label' => __('Image'),
        'title' => __('Image'),
        'required' => false,
        'disabled' => $isElementDisabled
    ]
);


texts:
TL;DR:
I would love an example of how Magento\Framework\TestFramework\Unit\Helper\ObjectManager::getCollectionMock() can be used for unit tests that involve collections and/or collection factories and a few words about how this works.

Long version

I'm trying to learn how to unit test my Magento 2 module.
I've reached the point where I need to test a class that has a dependency a collection factory.
So I need to mock this and return some dummy collection and I need a few items (can be 1) in this collection.
I found the method Magento\Framework\TestFramework\Unit\Helper\ObjectManager::getCollectionMock(), but I think I'm not using it properly because I always get an empty collection.

My class looks like this:

<?php
namespace Sample\News\Model\Source;

use Magento\Framework\Option\ArrayInterface;
use Magento\Directory\Model\ResourceModel\Country\CollectionFactory as CountryCollectionFactory;

class Country implements ArrayInterface
{
    /**
     * @var CollectionFactory
     */
    protected $countryCollectionFactory;
    /**
     * @var array
     */
    protected $options;

    /**
     * constructor
     *
     * @param CountryCollectionFactory $countryCollectionFactory
     */
    public function __construct(CountryCollectionFactory $countryCollectionFactory)
    {
        $this->countryCollectionFactory = $countryCollectionFactory;
    }

    /**
     * get options as key value pair
     *
     * @return array
     */
    public function toOptionArray()
    {
        if (is_null($this->options)) {
            $this->options = $this->countryCollectionFactory->create()->toOptionArray(' ');
        }
        return $this->options;
    }

    /**
     * @return array
     */
    public function getOptions()
    {
        $countryOptions = $this->toOptionArray();
        $_options = [];
        foreach ($countryOptions as $option) {
            $_options[$option['value']] = $option['label'];
        }
        return $_options;
    }
}

My test code looks like this:

<?php
namespace Sample\News\Test\Unit\Model\Source;

use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Directory\Model\ResourceModel\Country\CollectionFactory;
use Magento\Directory\Model\ResourceModel\Country\Collection;
use Sample\News\Model\Source\Country;

class CountryTest extends \PHPUnit_Framework_TestCase
{
    protected $objectManager;
    protected $countryCollectionFactoryMock;
    /**
     * @var Country
     */
    protected $countryList;
    protected function setUp()
    {
        $this->objectManager = new ObjectManager($this);
        $this->countryCollectionFactoryMock = $this->getMockBuilder(CollectionFactory::class)
            ->disableOriginalConstructor()
            ->getMock();
        $countryMock = $this->getMockBuilder('\Magento\Directory\Model\Country')
            ->disableOriginalConstructor()
            ->getMock();
        $countryMock->method('getId')->willReturn(1);
        $countryMock->method('getTitle')->willReturn('Romania');

        $collection = $this->objectManager->getCollectionMock(Collection::class, [$countryMock]);
        $this->countryCollectionFactoryMock->method('create')->willReturn($collection);
        $this->countryList = $this->objectManager->getObject(
            Country::class,
            [
                'countryCollectionFactory' => $this->countryCollectionFactoryMock
            ]
        );
    }
    public function testToOptionArray()
    {
        $this->assertEquals(['1' => 'Romania'], $this->countryList->toOptionArray());
    }
}

My test fails saying that

  null does not match expected type "array".

So I assume I'm using the getCollectionMock method wrongly.
I don't actually need someone to debug my code (though it would be nice), I would accept an example on how to use getCollectionMock and a few words about how it works.


texts: Modify Login Error Messages in Magento 2.3 for Incorrect Password

texts:
I'm looking to change the "The account sign-in was incorrect or your account is disabled temporarily. Please wait and try again later." message that appears when someone types an incorrect password.
I see the text in .xml files in vendor/magento/module_customer, but I don't think these are the files I should rewrite. What file should I overwrite with a new module?


texts: Refused to execute script from '' after moving from dev to production

texts:
When moved to production, with enabled js file bundling, i start to get these types of errors in browser console:

Refused to execute script from 'http://ultra.com/static/frontend/RocketTeam/ultra/ru_RU/requirejs/require.min.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

Well, i check my files and it seems like i have them all in pub/static folder. So, for this http://ultra.com/static/frontend/RocketTeam/ultra/ru_RU/requirejs/require.min.js i have a file in my filesystem here:

magento/pub/static/frontend/RocketTeam/ultra/ru_RU/requirejs/require.js

When i try to reach these files via links from the browser console, i get 404.

As i understand my server returns me the wrong MIME type for js files. But why this happens? In developer mode everything works fine.

I just executed php bin/magento deploy:mode:set production and had output in the console similar to what is shown in documentation.

Magento 2.2 running locally in a docker container,
php 7.0.18

UPD: Ok, i was stupid, i don't have minified version of files in my filesystem. Ok, but why minification didn't happen?

UPD: Thanks to @PramodKharade, i managed to make it work.
What i did was:

after switching to production mode i cleaned and flushed caches, deleted generated folders, ran the setup, compiled code, and deployed static content:

rm -rf pub/static/*
rm -rf var
php bin/magento c:c
php bin/magento c:f
php bin/magento set:up
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy --language ru_RU


texts: How can I retrieve table name from Magento collection. My case: observer listens catalog_product_collection_load_before event. Here we can get product collection. But I need exactly which table is used for this collection. Magento uses flat tables if it is enabled, otherwise catalog_product_entity table. I have enabled flat tables but sometimes Magento uses eav table for product collection (on catalog/category/view request). Any suggestions will be appreciated.


texts: How to load custom template file for product detail page in magento2

texts:
I am looking for code how we can load custom template file for product detail page?

I need to remove default magento2 detail page,

I have tried below code to achieve it,

 {{block class="Magento\Framework\View\Element\Template" name="product_file" template="Magento_Catalog::product.phtml"}}

I created new cms page, and from category list page, I am redirecting to this page for each of the products by passing parameter with productId.

In detail page i used below code to get product data.

$proId = $_REQUEST['id'];
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$product = $objectManager->create('Magento\Catalog\Model\Product')->load($proId);
$proSku  = $product->getSku();
$product_title = $product->getName();

Is this can be achieved any other simple way?


texts: change UNIQUE KEY in customer entity table properties with setup script

texts:
magento customer_entity table structure is like:

CREATE TABLE `customer_entity` (
  `entity_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Entity Id',
  `entity_type_id` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Entity Type Id',
  `attribute_set_id` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Attribute Set Id',
  `website_id` smallint(5) unsigned DEFAULT NULL COMMENT 'Website Id',
  `email` varchar(255) DEFAULT NULL COMMENT 'Email',
  `group_id` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Group Id',
  `increment_id` varchar(50) DEFAULT NULL COMMENT 'Increment Id',
  `store_id` smallint(5) unsigned DEFAULT '0' COMMENT 'Store Id',
  `created_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT 'Created At',
  `updated_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT 'Updated At',
  `is_active` smallint(5) unsigned NOT NULL DEFAULT '1' COMMENT 'Is Active',
  `disable_auto_group_change` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Disable automatic group change based on VAT ID',
  PRIMARY KEY (`entity_id`),
  UNIQUE KEY `UNQ_CUSTOMER_ENTITY_EMAIL_WEBSITE_ID` (`email`,`website_id`),
  ...

is it possible to alter the table with install (migration) script to remove UNIQUE KEY property?


texts: Magento 1.9 onepage checkout and PayPal order review issue

texts:
Our normal checkout (onepage) flow is this:

1.) Cart
2.) Billing/shipping information
3.) Payment method
4.) Review

When moving from step 3 to step 4, checkout/onepage/savePayment/ is called. If selected payment method is NOT PayPal, user is then shown the last step of checkout if is review (on the same page).

However, if selected payment method is PayPal, user is then redirected to paypal/checkout/review page which is not the same as the last step in Onepage checkout flow.

If Skip order review page is set to Yes then the last step is completely skipped.

Is there a proper way to solve this issue?

Any help or guidance is much appreciated.


texts: Magento 2: Invoice PDF update google fonts possible?

texts:
I want to update Logo in Invoice Pdf.

Also, I am looking for update google fonts.

I am looking for any solution but not getting an exact answer. Should I go through custom module and override pdf module Or is there any solution is available in back-end?

If anyone does it please let me know.


texts: Update customer address attribute value in Magento

texts:
I have to remove leading and trailing spaces from address postcodes.

The following script does the task:

<?php
require('./app/Mage.php');
Mage::init();

$addresses = Mage::getModel('customer/address')->getCollection();

foreach( $addresses as $row ) {
    $address = Mage::getModel('customer/address')->load( $row->getId()   );

    $address->setData( 'postcode', trim( $address->getPostcode() ) ) //remove spaces
            ->getResource()
            ->saveAttribute( $address, 'postcode' );
}

Is there any better solution? Can/should it be done directly via MySQL database query?


texts:
Here is the plugin i created for limiting 3 products can be added into comparison. But it not loading, add one know what is the problem?
etc/frontend/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\Controller\Product\Compare\Add">
        <plugin name="LimitToCompareProducts"
                type="Custom\TestCompare\Plugin\LimitToCompareProducts"/>
    </type>
</config>

etc/module.xml
<?xml version="1.0"?>
<!--
/**
 *
 */
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
    <module name="Custom_TestCompare" setup_version="1.0.0"/>
</config>

Plugin/LimitToCompareProducts.php
<?php

namespace Custom\TestCompare\Plugin;

    use Magento\Framework\Controller\Result\RedirectFactory;
    use Magento\Framework\Message\ManagerInterface;
    use Magento\Catalog\Helper\Product\Compare;

    class LimitToCompareProducts
    {
        const LIMIT_TO_COMPARE_PRODUCTS = 3;

        /**
         * @var \Magento\Framework\Message\ManagerInterface
         */
        protected $messageManager;

        /**
         * @var RedirectFactory
         */
        protected $resultRedirectFactory;

        /** @var Compare */
        protected $helper;

        /**
         * RestrictCustomerEmail constructor.
         * @param Compare $helper
         * @param RedirectFactory $redirectFactory
         * @param ManagerInterface $messageManager
         */
        public function __construct(
            RedirectFactory $redirectFactory,
            Compare $helper,
            ManagerInterface $messageManager
        )
        {
            $this->helper = $helper;
            $this->resultRedirectFactory = $redirectFactory;
            $this->messageManager = $messageManager;
        }

        public function aroundExecute(
            \Magento\Catalog\Controller\Product\Compare\Add $subject,
            \Closure $proceed
        ){

            $count = $this->helper->getItemCount();
            if($count > self::LIMIT_TO_COMPARE_PRODUCTS) {
                $this->messageManager->addErrorMessage(
                    'You can add the compared products under 3 item(s)'
                );

                /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
                $resultRedirect = $this->resultRedirectFactory->create();
                return $resultRedirect->setRefererOrBaseUrl();
            }

            return $proceed();
        }
    }

registration.php
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'Custom_TestCompare',
    __DIR__
);


texts: Magento 2 > Get 'free shipping' minimum order value

texts:
In Magento 2.1.x Lets say I want to show the minimum order amount for free shipping in a block somewhere in my website, how can I retrieve this value?

The setting has been configured in Stores > Configuration > Sales > Shipping Methods > Free Shipping > **Minimum Order Amount**


texts: How to override function getAdditionalData() of block Magento\Catalog\Block\Product\View\Attributes.php file

texts:
How to override function getAdditionalData() of Attributes.php file in magento 2.

di.xml file code,

<?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\Catalog\Block\Product\View\Attributes" type="Test\Details\Block\Attribute"/>
</config>

Block file code,

<?php
namespace Test\Details\Block;

class Attribute extends \Magento\Catalog\Block\Product\View\Attributes
{

    public function getAdditionalData(array $excludeAttr = [])
    {
        $data = [];
        $product = $this->getProduct();
        $attributes = $product->getAttributes();
        foreach ($attributes as $attribute) {
            if ($attribute->getIsVisibleOnFront() && !in_array($attribute->getAttributeCode(), $excludeAttr)) {
                $value = $attribute->getFrontend()->getValue($product);

                if (!$product->hasData($attribute->getAttributeCode())) {
                    $value = __('N/A');
                } elseif ((string)$value == '') {
                    $value = __('No');
                } elseif ($attribute->getFrontendInput() == 'price' && is_string($value)) {
                    $value = $this->priceCurrency->convertAndFormat($value);
                }

//i have to remove if condtion from this function here....
                    $data[$attribute->getAttributeCode()] = [
                        'label' => __($attribute->getStoreLabel()),
                        'value' => $value,
                        'code' => $attribute->getAttributeCode(),
                    ];
            }
        }
        return $data;
    }
}

After override block, Main information tab is remove automatically,
I have to work in main information tab of product detail page.

i have checked log file and log error are display like this,

main.CRITICAL: Invalid template file: 'product/view/attributes.phtml' in module: 'Test_Details' block's name: 'product.attributes' [] [].

Any suggestion for issue?


texts: I have to create a REST API that can be used in android phone to list all the products including product image using category id ?


texts: Remove cart from page bottom footer area

texts:
I Have Showing In My Website Cart In footer Area So Please Tell Me How To I Can Remove From here...
I Have Tried To Edit Addtocart.phtml but there is i have not found any valuable response...
my Website Url Is mkzon.com u Can See Here....


texts:
my Magento 2 runs in developer mode and I'm trying to install my first selfwritten extension by CLI.
The install itself works nice, but when running the setup:upgrade command, it can't find the injected Factories in my UpgradeData.php scripts.

Here a condensed version of the code:

public function _construct(
    \Vendor\Extension\Model\DepartmentFactory $departmentFactory,
    \Vendor\Extension\Model\EmployeeFactory $employeeFactory
)
{
    $this->departmentFactory = $departmentFactory;
    $this->employeeFactory = $employeeFactory;
    ...
    $salesDepartment = $this->departmentFactory->create();
    ...
}

PHP Fatal error:  Uncaught Error: Call to a member function create() on null in /var/www/html/magento/app/code/Vendor/Extension/Setup/UpgradeData.php:30

Not even the Magento\Framework\Code\Generator\Autoloader is requested at this point. Many other classes are successfully requested an generated while running other setup:upgrade tasks on earlier modules, but here, the Autoloader is not called at all (checked that by echoing in the class).

As far as I understood, neither do I need to write this classes, nor do I have to write a preference for it. Please correct me if I'm wrong.

So what could the problem be? What do I have to change?

Many thanks.


texts: Is it possible to create a non-ecommerce site using Magento?

texts:
I have a site to develop that needs to be a kind of voucher code site. This means that the site will provide voucher codes for other sites, the user will come to my site and pick voucher codes for another site and will then redirect to the target site. In short, it does not need any Add-to-Cart functionality of magento.

  An example site is shown below in link: https://www.promothecode.com/coupon/chiquito

However, the site I plan to create requires a strong Admin side for Support, so I believe Magento has a strong Admin interface and that is the reason why I am planning to choose Magento for my site. So my questions are:

Is it good to use magento for developing such non e-commerce sites
What are the best practices that should take care of when developing such sites using magento

Please share your thoughts... Thanks in advance!


texts: How to disable ratings & reviews in listing page?

texts: I would like to disable rating and reviews link from category listing page. There is no option in admin system configuration. I couldn't find referenceBlock in catalog_category_view.xml.


texts:
I'm getting error messages when trying to update my magento installation via the admin panel.

When I log on to my server and give the command crontab -l the only 1 listed is
MAILTO="".

The magento documentation states that the output should be

* * * * * /usr/bin/php /var/www/html/magento2/bin/magento cron:run 2>&1 | grep -v "Ran jobs by schedule" >> /var/www/html/magento2/var/log/magento.cron.log
* * * * * /usr/bin/php /var/www/html/magento2/update/cron.php >> /var/www/html/magento2/var/log/update.cron.log
* * * * * /usr/bin/php /var/www/html/magento2/bin/magento setup:cron:run >> /var/www/html/magento2/var/log/setup.cron.log
#~ MAGENTO END c5f9e5ed71cceaabc4d4fd9b3e827a2b

I then run  php bin/magento crontab:install -f but this doesn't change the output from MAILTO=""


texts: Is it Magento 2.2.3 to 2.2.8 version support ElasticSearch 7.1.1?

texts:
I am using Magento Version 2.2.3.

And my current version of Elastic Search is 6.2.4.

But my search result are not coming correct.Can I Update my ElasticSearch version to 7.1 or more in this magento 2.2.3 version.


texts:
I'm trying install Czech language pack  via composer from mageplaza:
https://www.mageplaza.com/magento-2-czech-language-pack.html

When I run then get issue:

 Problem 1
    - Installation request for mageplaza/magento-2-czech-language-pack dev-maste                                 r -> satisfiable by mageplaza/magento-2-czech-language-pack[dev-master].
    - Conclusion: don't install mageplaza/module-core 1.4.1
    - Can only install one of: mageplaza/module-core[1.3.13, 1.3.12].
    - Can only install one of: mageplaza/module-core[1.3.13, 1.3.12].
    - Can only install one of: mageplaza/module-core[1.3.13, 1.3.12].
    - mageplaza/magento-2-czech-language-pack dev-master requires mageplaza/modu                                 le-core ^1.3.13|dev-master -> satisfiable by mageplaza/module-core[1.3.13, 1.4.0                                 , 1.4.1].
    - Conclusion: don't install mageplaza/module-core 1.4.0
    - Installation request for mageplaza/module-core (locked at 1.3.12, required                                  as ^1.3) -> satisfiable by mageplaza/module-core[1.3.12].

I understand I need to upgrade module-core.

Can anyone confirm I update module-core in this way? (now website is on live and I would not want to have any complications).

$ composer require mageplaza/module-core:1.4.1 --no-update
$ composer update


texts: Ultimate Module Creator Image Helper very slow

texts:
I used the Ultimate Module Creator (UMC) to create a simple Admin interface for adding and editing a custom entity type in Magento. Three of the attributes are images, so UMC creates an abstract image helper and then an image helper that extends that which is specific to the entity type. You can see the source template for the class that it builds here.

The problem is that, even though images are being saved to the cache, just calling init() in the helper takes about 0.5 seconds. This really adds up, and is slowing down any page where we use this custom helper.

The method in question is below:

/**
 * init image
 * @access public
 *
 * @param Varien_Object $object
 * @param string $imageField
 *
 * @return MyCompany_MyModule_Helper_Image_Abstract
 */
public function init(Varien_Object $object, $imageField = 'image') {
    $this->_imageProcessor = null;
    $this->_image          = $object->getDataUsingMethod($imageField);
    if (!$this->_image) {
        $this->_image = '/' . $this->_placeholder;
    }
    $this->_widht           = null;
    $this->_height          = null;
    $this->_scheduledResize = false;
    $this->_resized         = false;
    $this->_adaptiveResize  = 'center';

    try {
        $this->_getImageProcessor()->open($this->getImageBaseDir() . $this->_image);
    } catch (Exception $e) {
        $this->_openError = $e->getMessage();
        try {
            $this->_getImageProcessor()->open(Mage::getDesign()->getSkinUrl($this->_placeholder));
            $this->_image = '/' . $this->_placeholder;
        } catch (Exception $e) {
            $this->_openError .= "\n" . $e->getMessage();
            $this->_image = null;
        }
    }

    return $this;
}

Does anyone know why this is so slow? (Again, the whole class is linked to above.)

If not, can anyone suggest an alternative for use on the front-end? I am just assuming that Mage_Catalog_Helper_Image shouldn't be used (and may not be able to be used) for any non-Catalog image. Is that correct?


texts: how to change the custom option value to download link in magento 2 order

texts:
Hi I have created a custom option for product

  working fine in the front end

  When I order this product

  in  order view the product custom option showing as text

  I need as the download link

  How I can do this????


texts: change quantity input to dropdown for user definable quantities in bundle items

texts:
How can I replace the text field for user definable quantities on bundle products with a dropdown menu?

Example here: https://www.sconch.com/test-bundle - see Test Item 1

I've managed to replace all other quantity fields with dropdowns but can't work out how to do it for the constituent parts of bundle products

Thanks,

Hugh


texts: How to add multiple quantities of a single product to cart in product list view page of Magento 2?

texts: Currently the functionality is no matter how much quantity you enter in qty field, only one quantity gets added/updated to cart


texts:
Is there any way to add product attribute with different store labels through Magento2 setup script?

If we pass 'label'  it only assign default label of the attribute. I tried with frontend_label but that didn't worked.

$options =             [
        'type' => $type,
        'backend' => $input == 'multiselect'? 'Magento\Eav\Model\Entity\Attribute\Backend\ArrayBackend' : '',
        'frontend' => '',
        'label' => $attributeLabel,
        'frontend_label' =>  array(0=>$attributeLabel,1=>$attributeLabel.' test1',2=>"",3=>"",4=>"",5=>$attributeLabel.' test5',6=>"",7=>"",8=>""),
        'input' => $input,
        'class' => '',
        'source' => in_array($input, ['text', 'textarea', 'multiselect'])
            ? '' :'Magento\Eav\Model\Entity\Attribute\Source\Table',
        'global' => $is_Global ? \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_GLOBAL : \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE,
        'visible' => true,
        'required' => false,
        'user_defined' => true,
        'searchable' => true,
        'filterable' => $isFilter,
        'comparable' => true,
        'visible_on_front' => $showOnProductPage,
        'used_in_product_listing' => $usedInProductListing,
        'unique' => false,
        'group' => $group,
        'apply_to' => '',
        'wysiwyg_enabled' => $wysiwyg,
    ];

    $eavSetup->addAttribute(
        \Magento\Catalog\Model\Product::ENTITY,
        $attributeCode,
        $options
    );


texts:
I Have one "HTML" theme and want to Integrate into Magento2. I am Already Created Folder structure of the theme. But Don't know how to add header part, footer part in which files. and in which file define theme's "CSS", "JS" etc..

"My Theme Structure"

I have ".css" files for adding css.

Output

I Want to Like This:

So can anyone help me? I am using Magento version: 2.2.0


texts: Magento 2, get field backend model by path

texts:
I'm making a plugin for the Magento\Framework\App\Config\ScopeConfigInterface file.

I need to get the config value from database.

Right now, I manage to accomplish this, but I'm having an issue with obscured fields.

I'm getting the value that comes directly from database.

If I inject the EncryptorInterface I can decrypt it, but the problem is that I need to know when is necessary to decrypt and when should I need to return the value from database.

I have at this point of the flow the path for the config option (example: carriers/usps/userid )

I was looking for a way to detect the backend model for the field using the path to load the model.

I tried something like this:

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$field = $objectManager->create('Magento\Config\Model\Config\Structure')->getElement($path);

And then try this to get the backend Model:

    if ($field->hasBackendModel()) {
        $backendModel = $field->getBackendModel();
        //backend model is empty
    }

Not sure how I can achieve to detect if the field has backend model Magento\Config\Model\Config\Backend\Encrypted

Is there some way to read the xml tree, and using the field path get the backend model, so I can know if I should use decrypt for returning the value or not?


texts: How to get count of active category children - Magento 2

texts:
Now I receive children number using this code:

$currentCategory = $this->getCurrentCategory();
$childrenCount = $currentCategory->getChildrenCount();

But it counts both enabled and disabled children.

Do you know method that counts only enabled children, or I have to filter them in block?


texts: Can't get value from attribute "eancode"

texts:
I want to export some orders from Magento 1.7, but I'm stuck on 1 thing. I have an attribute in Magento, named 'eancode'. I want to put the eancode from every product in the export, but it shows a blank field. I checked that the attribute contains some numbers for the exported products.

In csv.php I have:

/**
 * Returns the item specific values.
 *
 * @param Mage_Sales_Model_Order_Item $item The item to get values from
 * @param Mage_Sales_Model_Order $order The order the item belongs to
 * @return Array The array containing the item specific values
 */
protected function getOrderItemValues($item, $order, $itemInc=1)
{
    return array(
        $itemInc,
        $this->geteancode($item),
        $item->getName(),
    );
}

  }

In abstractcsv.php I have:

/**
 * EAN code output
 *
 * @param Mage_Sales_Model_Order_Item $item The item to return info from
 * @return String The ean
 */
protected function geteancode($item)
{
$eancode = Mage::getModel('catalog/product')->load($item->getProduct()->getId())->geteancode();
return $item->geteancode();
}

Can you see what's going wrong? I've been troubleshooting and Googling for hours now, but I can't find the problem.

Thank you!


texts: Magento 1.7 Shopping cart rule, category not obeyed when config product in cart

texts:
Let's keep it simple, I have the following categories:

Caps (ID: 1)
Accessorries (ID:2)

I have the following rule:

"Any 3 caps , 10% OFF (discount applied to caps only)"

And now I have the following items in the cart with the following results:

3 caps (3 Simple Products) - Rule runs - Expected
2 caps (2 Simple Products) and 1 Accessory (simple) - Rule Does not run - Expected
2 caps (1 Simple Product + 1 Config Product) and 1 Accessory (simple) - Rule Runs - NOT Expected
2 caps (1 Simple Product + 1 Config Product) - Rule does not run - Expected

As you can see in the above third scenario, there are 3 items in the cart. However, the shopping cart price rule does not obey categories when a configurable product (cap) was added to the cart.

This is for Magento 1.702 and I have done a diff compare of core files and there are no differences. Was wondering if anyone could reproduce the above or have a solution?

Many thanks.


texts: How can I perform 301 url redirection in Magento 2.0?

texts:
URL structure has been changed for one of product page in my Magento 2.0 webstore. Now I need to perform 301 redirection to newly created URL.

Is .htaccess still helpful here? If yes then please share code snippets or else suggest new technique.


texts: Getting Catalogsearch result in observer

texts:
I would like to get the product(Id)'s on a searchresult page in an observer which runs after the initial page render. But I can't seem to get it.
The results are fetched by: \Mage_Catalog_Block_Product_List::_getProductCollection

But I don't know how to get that in an observer.
Does anybody know how to do that.


texts: How to get or append some extra query param to url

texts:
I have added some links in top. i want get query param from url and append in to every links in top dynamically

like my links are =  test1,  test2, test3

My mail url is = https://apcd.com

When some one use = https://abcd.com?id=123

When any one click on any link in top normally it will open like =  https://abcd.com/test1 but i need https://abcd.com/test1?id=123

I am able to add like this but user changed https://abcd.com?id=1234 immediately not effecting in to that links when i flush cache that time only it effecting any idea to resolve this issue

I have create one phmtl file

 <?php  $blockObject= $block->getLayout()->createBlock('Pawan\Customerids\Block\Index');
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$storeManager = $objectManager->get('\Magento\Store\Model\StoreManagerInterface');
$id = $blockObject->getRequest()->getParam('id');

$storeurl=$storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_WEB);
$storeurl = rtrim($storeurl, '/');
?>

    <a href="<?php echo $storeurl.'/home'.$id; ?>" id="ui-id-3" class="ui-corner-all" tabindex="-1" role="menuitem">home

    <a href="<?php echo $storeurl.'/our-experts'.$id; ?>" id="ui-id-4" class="ui-corner-all" tabindex="-1" role="menuitem">OUR EXPERTS

    <a href="<?php echo $storeurl.'/about-us'.$id; ?>" id="ui-id-5" class="ui-corner-all" tabindex="-1" role="menuitem">ABOUT US

    <a href="<?php echo $storeurl.'/contact'.$id; ?>" id="ui-id-6" class="ui-corner-all" tabindex="-1" role="menuitem">SUPPORT

    <a href="<?php echo $storeurl.'/faq-s'.$id; ?>" id="ui-id-7" class="ui-corner-all" tabindex="-1" role="menuitem">FAQS

I called this file default_head_blocks.xml it i showing fine


texts: Magento 2 category image 404 with store code in url

texts:
I have a phtml file in my theme that is added to category page via XML updates tab.

I read image in phtml like so:

$this->getUrl('media/catalog/category/').$_category->getImageUrl()

My theme has 2 store view nl-be, fr-be and one of them has store code to url like so:

NL-BE = https://magento2.com/media/catalog/category/image.jpg

NL-FR = https://magento2.com/fr-be/media/catalog/category/image.jpg //THIS IMAGE GOES 404

Anyone any idea?


texts: Update record error : "Unique constraint violation found" in magento2

texts:
In the controller, I am inserting and updating data.
But when record is already exist it's not update it's again try to insert so i am getting above error:

if(!$checkoutPrescriptionCollection->count()) {
 $checkoutPrescription->setQuoteId($quoteId);
 $checkoutPrescription->setCustomerPrescriptionId($prescription);
 $checkoutPrescription->save();
}
else{
   $checkoutPrescription->load($quoteId,'quote_id');
   if($checkoutPrescription->getPrescriptionQuoteId()){
    $checkoutPrescription->setCustomerPrescriptionId($prescription);
    $checkoutPrescription->save();
    }
}

In xml file

<?xml version="1.0"?>
<!--
/*
 * Copyright © 2019 vendor. All rights reserved.
 * See COPYING.txt for license details
 */
-->
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
    <table comment="Customer Prescption Quote Table" engine="innodb" name="vendor_prescription_quote" resource="default">
        <column comment="Prescription Quote Id" identity="true" name="prescription_quote_id" nullable="false" padding="10" unsigned="true" xsi:type="int"/>
        <column comment="Quote Id" name="quote_id" nullable="false" padding="10" unsigned="true" xsi:type="int"/>
        <column comment="Prescription Id"  name="customer_prescription_id" nullable="false" padding="10" unsigned="true" xsi:type="int"/>
        <constraint referenceId="PRIMARY" xsi:type="primary">
            <column name="prescription_quote_id"/>
        </constraint>
       <!-- <constraint xsi:type="foreign" referenceId="CUSTOMER_PRESCRIPTION_ID" table="vendor_prescription_quote" column="customer_prescription_id" referenceTable="customer_prescription" referenceColumn="customer_prescription_id"/> -->
    </table>
</schema>


texts: How to send a javascript variable to a PHP file in Magento project?

texts:
I have this file that contains a javascript variable:

src/app/design/adminhtml/default/default/template/smv/order/sales/creditmemo/refund.phtml

<p>
    <select name="creditmemo[reason]">
        <option value="wrong">Fraudulent</option>
        <option value="not_available">Unavailable</option>
        <option value="request">Request</option>

    <script type="text/javascript">

            var cancelAndRefundSelectElement = document.getElementsByName("creditmemo[reason]")[0];

    </script>

</p>

Now, I need to send that variable to this PHP file:

src/app/code/code/Mage/Sales/model/Order/Creditmemo.php

public function reason(){

return
}

The problem is that I don't know how to call it from there and return it.

The code is longer, but I just wrote that the necessary things for the sake of the example.

Basically, how can I send the value of the variable from the 1st file (phtml) to the 2nd file (php)?

Thank you!


texts: Is there a way of nicely cleaning up the magento root folder after the site is set up eg files like php.ini.sample and folders like /setup?


texts: How to get the data of a category in my catalog?

texts:
I use these lines to get the data of a product in the catalog,

// Get product data.
$_helper = $this->helper('catalog/output');
$_product_id = Mage::registry('product')->getId();
$_product = Mage::getModel('catalog/product')->load($_product_id);

What about if I want to get the data of a category in the catalog?

$_helper    = $this->helper('catalog/output');
$_category  = $this->getCurrentCategory();
echo Mage::getModel('catalog/category')->load($_category->getId())->getThumbnail();

I get this error,

  Fatal error: Call to a member function getId() on a non-object in
  ...\default\template\page\html\banner-category.phtml on line 4

I tried with these as well but the same error,

$_helper = $this->helper('catalog/output');
$_category_id = Mage::registry('category')->getId();
echo Mage::getModel('catalog/category')->load($_category_id)->getThumbnail();

Any ideas?


texts: Wrong products after filtering attribute in layered navigation

texts:
I have a problem i try to solve for a while but i can find the exact issue.

The problem: after i filter a bulb type like H7, i also get products from another bulb type like HB4 so people can be confused what to order now.

I tried all possible combinations of attribute, refreshing cache, reindex but the wrong products still show up.(bulb type only for simple products, these simple products are used in bundle products.)

Has anyone has seen this issue before and have a solution for this?

this is a link for the issue

I use magento 1.9.4.2


texts:
I need to update the product code on the left of the image when the product options on the right change ?

Where would I need to make this change?


texts: Attributes not showing in sidebar categories

texts:
I have multiple products in my store which all have options or attributes like color, brand, size etc. I am working on a new shop which is located here: tfgsnew.hypernode.io. I cannot find out why it is not showing my shopping information on the left sidebar here:

http://tfgsnew.hypernode.io/fietsen/alle-fietsen

My theme builder cant find the problem either. Where should I start looking in settings or where can it go wrong? It doesn't display. It should be like this (located here: http://mas1.magikthemes.com/index.php/aspire/womens/clothing.html) :

What is going wrong?


texts: Select more than one item in layered navigation (multiple select/checkboxes)

texts:
How do you convert the standard layered navigation to use checkboxes or multiple select inputs for attributes of type dropdown or multiselect?

For example if a user selects blue and red for the color attribute, the layered navigation shows all items matching either blue OR red.

See example in toolbar on this page:


texts:
I'm trying to setup magento on magestead. However, I'm always getting an error during downloading the richdynamix/magestead-ubuntu14-nginx-php56 box.

The error is:

  An error occurred while downloading the remote file. The error
  message, if any, is reproduced below. Please fix this error and try
  again.

  SSL read: error:00000000:lib(0):func(0):reason(0), errno 104

Any idea on how to fix this?


texts: Magento Store Switcher display one store instead of all

texts:
I've create multiple website like below:

And in frontEnd i've displaying Store Switcher in the footer but my problem is not displaying all the stores defined above it will display only main website.

Any suggestion please?


texts:
I am a beginner to magento and I have created a magento 2 multi-website and the URL looks like http://127.0.0.1/testproject/ and http://127.0.0.1/testproject/test.

On these websites, while I have logged into http://127.0.0.1/testproject/ site, It will show the currently logged in username and compare products in the header link that's fine.

But in another tab I have logged into http://127.0.0.1/testproject/test site, It also keeps the first site logged-in username and compare products data.

Similarly if logged into http://127.0.0.1/testproject/test first means, this login username and compare products will be shown on another website(http://127.0.0.1/testproject/) also.

And I have set 'No' to share the customer between websites in configuration.
If I was removed the browser cache and session means, It will be showing correctly.

Thanks in advance.


texts: How to add a custom step in Magento 1.9 checkout

texts: anybody here have a guide or tutorial on how to add a new step on magento 1.9CE checkout page?


texts:
Been trying to figure out what is going on here, but gotten stuck. Anyone got an idea as to what is going on. Using magento 2.2.4

  ( ! ) Fatal error: Uncaught TypeError: Argument 1 passed to
  Magento\Catalog\Model\ProductRepository\Interceptor::getList() must be
  an instance of Magento\Framework\Api\SearchCriteriaInterface, string
  given in
  C:\wamp64\www\magento2\generated\code\Magento\Catalog\Model\ProductRepository\Interceptor.php
  on line 85
      ( ! ) TypeError: Argument 1 passed to Magento\Catalog\Model\ProductRepository\Interceptor::getList() must be
  an instance of Magento\Framework\Api\SearchCriteriaInterface, string
  given in
  C:\wamp64\www\magento2\generated\code\Magento\Catalog\Model\ProductRepository\Interceptor.php
  on line 85

Code I try to execute:

set_time_limit(0);
define('TOKEN', 'token code');
define('URL', 'http://localhost:8080/magento2/index.php');
$headers = array("Authorization: Bearer ". TOKEN);
//API URL to get all Magento 2 modules
$requestUrl = (URL . "/rest/V1/products?searchCriteria=");
$ch = curl_init($requestUrl);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
print_r($result);


texts: How do I remove subtotals from email confirmation email?

texts:
This is the content of totals.phtml:

<?php
foreach ($this->getTotals() as $_code => $_total): ?>
    <?php if ($_total->getBlockName()): ?>
        <?php echo $this->getChildHtml($_total->getBlockName(), false); ?>
    <?php else:?>
    <tr class="<?php echo $_code?>">
        <td <?php echo $this->getLabelProperties()?>>
            <?php if ($_total->getStrong()):?>
            <?php echo $this->escapeHtml($_total->getLabel());?>
            <?php else:?>
            <?php echo $this->escapeHtml($_total->getLabel());?>
            <?php endif?>

        <td <?php echo $this->getValueProperties()?>>
            <?php if ($_total->getStrong()):?>
            <?php echo $this->formatValue($_total) ?>
            <?php else:?>
            <?php echo $this->formatValue($_total) ?>
            <?php endif?>

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

I want to remove the subtotal from email confirmation but keep it in the  "Email Copy of Invoice" . How can I do that ?


texts: Is it upgrade safe to add custom address attributes

texts:
currently, I am developing a Magento extension, that needs to add several custom attributes to the customer address.
I've found several tutorials on the topic that describe precisely what I need to build
http://www.unexpectedit.com/magento/add-new-customer-attribute-onepage-magento-checkout
http://www.excellencemagentoblog.com/magento-adding-custom-field-to-customer-address

They all use ALTER TABLE to add columns to several DB tables. My question is :

Is it upgrade safely to do this?

Thanks in advance


texts: PHP set db value according to server datetime

texts:
Need to send notification to user by cron.
For that there is a datetime picker from which admin can select datetime.
IF datetime selected by datepicker is as below:

 $selecteddate = '26-9-2018 10:00';

 $defualttimzone = 'Asia/Kolkatta';

 $serverdate = date('d-m-Y H:i');

There is also a dropdown along with datetime picker with values:
       IND(GMT+3)
       USA(GMT-5)
       SAU(GMT+5)

Need to insert the date in database in reference to the current server's timezone and country selected along with datetime.
So that at exact time notification is sent to user.

       $milli = strtotime($selecteddate) * 1000;

Converted selected datetime to millseconds. Now i want to compare this milliseconds with server time and get difference and then get date from it to
insert in database.

Not getting how to move further. Any help would be appreciated.
Thankyou.


texts: Moving submenu in mobile responsive to top instead of bottom

texts:
What is the best way to move my sub category's menu from bottom to top?

In mobile responsive the menu is showing at bottom located at: \Magento\Catalog\Block\Navigation


texts: Since upgrading to 1.9.2 my import/export tool no longer works.  For exports I get a white screen and the imports stop with the please wait processing message.


texts: Magento 2 : Unable to View Customer's Listing Page in Admin

texts:
I am unable to view customers grid in admin. When I clicking on Customers ==> All Customers I get an error 500. Need help, which module might be corrupt or missing.

Thanks


texts: In Magento 2, What is use of setIsObjectNew while saving a model factory object?

texts:
Just curious to know What is use of setIsObjectNew while saving a model factory object, I see most of the time while creating console command it's set to true ?

Below is sample code used in Console command execute method:

$item = $this->itemFactory->create();
$item->setName($input->getArgument(self::INPUT_KEY_NAME));
$item->setDescription($input->getArgument(self::INPUT_KEY_DESCRIPTION));
$item->setIsObjectNew(true);
$item->save();

Thanks


texts: How to use the Out-of-Stock threshold option?

texts:
I see that I have the Out-of-Stock threshold in my admin panel, how could I use it in order to have more items in my products in stock then I really have?

And how does it works?


texts: Customer custom attribute value did not save using rest api in magento 2.3?

texts:
Customer custom attribute value did not save using rest API in Magento 2.3?
API URL: http://127.0.0.1/magento2/rest/V1/customers
Method: POST
My POST JSON request data is :
{
    "customer": {
        "email": "test@gmail.com",
        "firstname": "Tedst2",
        "lastname": "yosur",
        "store_id": 1
    },
    "password": "admin@123",
    "custom_attributes": [{
            "attribute_code": "test_attribute",
            "value": "simple"
        }
    ]
}

Setup-Script
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
    {

        /** @var CustomerSetup $customerSetup */
        $customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);

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

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

        $customerSetup->addAttribute(Customer::ENTITY, 'test_attribute', [
            'type' => 'varchar',
            'label' => 'test attribute',
            'input' => 'text',
            'required' => false,
            'visible' => true,
            'user_defined' => true,
            'sort_order' => 1000,
            'position' => 1000,
            'system' => 0,
        ]);
        //add attribute to attribute set
        $attribute = $customerSetup->getEavConfig()->getAttribute(Customer::ENTITY, 'test_attribute')
        ->addData([
            'attribute_set_id' => $attributeSetId,
            'attribute_group_id' => $attributeGroupId,
            'used_in_forms' => ['adminhtml_customer'],
        ]);

        $attribute->save();

    }

The Customer is created but the test_attribute is not "simple". Is there anyone who had the same problem and fixed it? Please let me know how to resolve it?.or any another way to save?


texts:
I'm trying to add custom block module to homepage but it does not load my block.phtml file. Here are my files:
app/etc/modules/MG_Block.xml:

<config>
    <modules>
        <MG_MyBlock>
            <active>true</active>
            <codePool>local</codePool>
        </MG_MyBlock>
    </modules>
</config>

app/code/local/MG/MyBlock/etc/config.xml:

<config>
    <modules>
        <MG_MyBlock>
            <version>0.1.0</version>
        </MG_MyBlock>
    </modules>
    <global>
        <blocks>
            <mg_myblock>
                <class>MG_MyBlock_Block</class>
            </mg_myblock>
        </blocks>
    </global>
</config>`

app/code/local/MG/MyBlock/Block/Products.php:

class MG_MyBlock_Block_Products extends Mage_Core_Block_Abstract{
    public function index(){
        return "hello world";
    }
}

app/design/frontend/rwd/default/template/mg/products.phtml:

<?php echo $this->index(); ?>

app/design/frontend/rwd/default/layout/local.xml:

<layout version="0.1.0">
    <default>
        <reference name="content">
            <block type="mg_myblock/products" output="toHtml" name="myblock" template="mg/products.phtml" after="-" />
        </reference>
    </default>
</layout>

When I use var_dump in _construct() function in my block it shows var_dump but it does not load template file.


texts:
When I enter a search query, Magento returns "no results". I am not using any search-related extensions. Already tried reindexing.

Where should I start debugging this?

I am running Magento 2.2.8


texts: When to set production mode in Magento 2

texts: why should I set production mode and when it's the correct time to do it?


texts: Unable to Add widget for New products in Hompage Using Magento 2 release alpha96

texts:
Anybody can guide me on how to display products in homepage in Magento 2?
In Magento 2 Backend, Content->Pages->Home Page->Content,
I am trying to insert Widget for New products on homepage but I am not successful.


texts: Magento 2 how to add image field in product attribute dropdown?

texts:
how to add image field in product attribute dropdown?
Please check below 2 image

magento 1

Magento 2

you can check in both image in Magento 1 image there are 3-4 fields extra like flag image, thumbnail, image.

how can we do the same in Magento 2?

I am only able to create yes-no fields in attribute under Storefront Properties tab.


texts: How to get Product Id from Item Object in Observer?

texts:
Controller File:

public function editAction()
{
   $quoteId=$this->getRequest()->getParam("quoteid");
   $quote = Mage::getModel('sales/quote')->load($quoteId);
   Mage::dispatchEvent('checkout_cart_product_add_after', $quote);
}

Observer File:

public function changePrice($observer) {
$item = $observer->getEvent()->getQuote();
echo "<pre>";print_r($item->getProductId());
exit();

How to get Product Id in Observer from Item?

If you have any idea then share here please.

Thank You.


texts: Array of product ids for a given category (respecting is_anchor)

texts:
I am trying to find the fastest way of getting a list/array of product id's for any given category id.

I understand this is quite fast $category = new Varien_Object(array('id'=>$_cat));
$positions = Mage::getResourceModel('catalog/category')->getProductsPosition($category);

but there must be a way of getting the individual id's in 1 go.

So my question is: how can I retrieve an array of productids from a category id?

(Ad. where the is_anchor attribute is respected - for this Magento this means that also underlying category products are added to the collection)

also read; http://www.blog.plazathemes.com/archives/2759


texts: Rewrite Wishlist Controller (IndexController)

texts:
I'm trying to rewrite a controller function but somehow I have somewhere an error:

In config.xml:

<frontend>
        <routers>
            <wishlist>
                <args>
                    <modules>
                        <Bm_SpamProtect before="Mage_Wishlist_IndexController">
                            Bm_SpamProtect
                        </Bm_SpamProtect>
                    </modules>
                </args>
            </wishlist>
        </routers>
    </frontend>

Start of my IndexController.php in my Module:

<?php

    require_once Mage::getModuleDir('controllers', 'Mage_Wishlist').DS.'IndexController.php';

    class Bm_SpamProtect_IndexController extends Mage_Wishlist_IndexController {

....

     }

However, the function is still returning the original code instead of my one. Wheres the error?


texts: Magento 1.9 Warning: require_once and Fatal error: require_once

texts:
Anyone, can you help me how to solve this?

Warning: require_once(/srv/app/Mage.php): failed to open stream: No
such file or directory in /srv/public_html/abstract.php on line 85
Fatal error: require_once(): Failed opening required
'/srv/app/Mage.php' (include_path='.:/usr/local/lib/php') in
/srv/public_html/abstract.php on line 85


texts: Magento Commerce Cloud - Accessing apple-app-site-association file from root path

texts:
For iOS application universal linking Unable to access apple-app-site-association file from the root path (/pub). Although its accessible from the pub/media but as per apple documentation this file should be accessible from root path only.
I have tried its redirection using the custom VCL snippets although its not working.
Is their any alternate to access this file from root path.


texts: Magento 2.3.2: setup:di:compile not working getting out in command line after 14%

texts:
Hey there i am trying to run command setup:di:compile . its getting started but and stopping for sometimes on 14% and then its gettin out back to cli.

i am not getting any error or exception so that i can solve it.

i have tried cache:flush , removed cache folder , removed generated folder but did not worked

how can i solve this issue help me to get the solution.

Big thanks in Advance :)


texts: how to connect my android application with database(mySql) by using magento

texts:
I am using android studio for development of android eCommerce application. i want to connect my application to magento. i am new developer so i have not too much knowledge about this.

My database is in mysql and mysql connect to magento. so how my app will connect to magento?
If I connect my app to magento through web service but i have no idea about how to connect through web service to magento.


texts:
How can one using csv file to translate from wysiwyg field: e.g

I have in the backend of Magento a field :

Opening Hours

Monday - 10am to 5pm
Tuesday - 10am to 5pm
Wednesday - 10am to 5pm
Thursday - 10am to 7pm
Friday - 10am to 5pm
Saturday - 10am to 5pm
Sunday - 11am to 5pm

to e.g Ducth:
    Openingstijden
    Maandag - 10:00 tot 17:00 uur
    Dinsdag - van 10:00 tot 17:00 uur
    Woensdag - 10.00 tot 17.00 uur
    Donderdag - 10.00 tot 19.00 uur
    Vrijdag - van 10:00 tot 17:00 uur
    Zaterdag: van 10:00 tot 17:00 uur
    Zondag - 11:00 tot 17:00 uur

I've tried in the csv file:

  "Opening Hours Monday - 10am to 5pm Tuesday - 10am to 5pm Wednesday - 10am to 5pm Thursday - 10am to 7pm Friday - 10am to 5pm Saturday - 10am to 5pm Sunday - 11am to 5pm","Openingstijden maandag Maandag - 10:00 tot 17:00 uur Dinsdag - van 10:00 tot 17:00 uur Woensdag - 10.00 tot 17.00 uur Donderdag - 10.00 tot 19.00 uur Vrijdag - van 10:00 tot 17:00 uur Zaterdag: van 10:00 tot 17:00 uur Zondag - 11:00 tot 17:00 uur",module,module,My_Module

I am calling at the front end like so:

<?php echo __("%1", $block->getOpeningHours());?>

I've also tried in the csv file like so:

  "%1","%1",module,My_Module

But that isn't translating!thanks


texts:
Hi I'm trying to run the indexer for a website using the cron.  I have the timing set correctly but the command is not working, probably something simple but any ideas people?

/opt/plesk/php/5.5/php -f /var/www/vhosts/aropec.co.uk/shell/indexer.php reindexall


texts:
I want to create iOS and Android apps for my Magento store.

For this purpose I want to know  which API method is best as app data API.

Please suggest below of option of Magento:

Soap Api
Rest Api
Create Custom module, controller and send JSON
Magento Default mobile apps XML Connection (Refer What API does the Magento Mobile Store native app use?)

I have read Alan Storm's answer. As per his suggestion my third option is best.

But I want to know which process for best for below condition:

Authentication
Faster Data fetch
Faster development

Please help me. Describe briefly


texts: set x-frame-options in custom controller magento2

texts:
I have a custom controller with below code.

namespace Vendor\Module\Controller\Service;
class Login extends \Magento\Framework\App\Action\Action{
protected $_storeManager;
protected $_customerFactory;
protected $_customerSession;
protected $_addressRepository;
protected $_addressDataFactory;
protected $addressFactory;
protected $customerRepository;
protected $checkoutSession;
private $logger;
protected $cart;
public function __construct(
    \Magento\Framework\App\Action\Context $context,
    \Magento\Store\Model\StoreManagerInterface $storeManager,
    \Magento\Customer\Model\CustomerFactory $customerFactory,
    \Magento\Customer\Model\Session $customerSession,
    \Magento\Checkout\Model\Session $checkoutSession,
    \Magento\Checkout\Model\Cart $cart,
    \Magento\Customer\Api\AddressRepositoryInterface $addressRepository,
    \Magento\Customer\Api\Data\AddressInterface $addressDataFactory,
    \Magento\Customer\Model\AddressFactory $addressFactory,
    \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository,
    \Psr\Log\LoggerInterface $logger
) {
    $this->_storeManager     = $storeManager;
    $this->_customerFactory  = $customerFactory;
    $this->cart = $cart;
    $this->_customerSession = $customerSession;
    $this->_addressRepository = $addressRepository;
    $this->_addressDataFactory = $addressDataFactory;
    $this->_addressFactory = $addressFactory;
    $this->checkoutSession = $checkoutSession;
    $this->customerRepository = $customerRepository;
    $this->logger = $logger;
    parent::__construct($context);
}

public function execute() {
    $customerPin = $this->getRequest()->getParam('pin');
    echo $customerPin;die;

}

Above code reads the parameter pin from the url and display the parameter value.

http://www.example.com/test/service/login/pin/6

This works only if accessed in the same website. Suppose the controller is accessed like iframe, from the other domain. its showing blank screen.

is there any setting to be done? from research i found we need to set X-Frame-Options to make it work.

if so how that can be set from controller?

Can anyone look into this and update me the solution please.


texts: UI Component Listing - transform user ID to the user name

texts:
I've created a model management pages in admin by UI Component. When saving this model, the controller will save the user id of creator to the table then show this on the model listing page. It is simple to achieve:

<column name="creator_id">
    <argument name="data" xsi:type="array">
        <item name="config" xsi:type="array">
            <item name="filter" xsi:type="string">text</item>
            <item name="label" xsi:type="string" translate="true">Creator Id</item>
        </item>
    </argument>
</column>

But, user id is difficult to distinguish. So, now I want to transform the creator ID to the user Name, how to achieve that?

  Notice the model table has the user_id column, but doesn't have the user_name. The UI Component need to use the user_id to get user_name, then put the name in the listing page.


texts: "not visibile individually" products showing up on front end

texts:
I am importing a bunch of skus into magento. I worked out a system to finally get it working properly with images that work etc.

However I stopped after a while and now I came back to it, and after importing a bunch of skus that are not supposed to be visible individually, they all show on the front end of the site.

I checked the product in admin, and the option is selected to not show individually.

another issue I am having.. that I had before but I thought I fixed. The country_of_manufacture column is not being imported. The last time that did not work I had to make sure that the country "Canada" was an option in the country_of_manufacture attribute. Which it is now.. But I am getting that issue again.


texts: Magento 2: Need to restrict licence key as per multisite and multistore view in custom extension

texts:
I need to restrict the license key for multisite and multistore views.
This would be valid only for default config, if they want to run the extension in other store or multisite then it will give an error with the same key.
How I can achieve?
Currently, I am doing this.
 $domain = $this->_storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_WEB, true);
        $response= $this->_api->expiryResponse($licencekey, $domain);

But this is showing the main domain in every store and site config.
I want if this is another website then it shows that that website URL instead of the default site URL.
Does anyone have any idea for the same?
Thanks


texts: Magento2: FullText Search Programatically

texts:
Does anyone know how to run a search using FullText and a string?

I'm trying to inject

use Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection as Fulltext;

and do

$this->_fulltext->addSearchFilter("wat");
$products = $this->_fulltext->getItems();

but the result is always empty.

Any idea?


texts: Magento 2.3.5-p - Show product page > product image alt and title tag (replaced fotorama gallery)

texts:
I'm using the following code to replace the fotorama image gallery on the product page based on this article.

app\design\frontend\Mypackage\mytheme\Magento_Catalog\templates\product\view\gallery.phtml

<?php

$product = $block->getProduct();
$imageHelper = $this->helper('Magento\Catalog\Helper\Image');

if (!$product->getImage() || $product->getImage() == 'no_selection') {
    $image = $imageHelper->getDefaultPlaceholderUrl('image');
} else {
    $image = $imageHelper->init($product, 'product_page_image_medium')
            ->constrainOnly(true)->keepAspectRatio(true)->keepFrame(false)
            ->setImageFile($product->getImage())
            ->getUrl();
}
?>

    <img src="<?php echo $image; ?>" >

However the alt tag isn't formatted correctly, it shows as "thisisanexampleimage" instead of "This is an example image" as defined under that product

Image and Video >> Image detail

How can I get the alt tag to show a properly formatted alt tag and also include a title tag.


texts: Layered Navigation categories to start one level down

texts:
We have the standard magento layered navigation down the side of our search page and it works fine except when you search the only category that shows up in "All Categories" and you have to click on that to then see sub categories (in pics below)

My categories are layed out like this

Index

-> All categories

->3M Littmann Stethoscopes

I couldnt find anything if relavance in the filter.phtml and i didnt really understand the Category.php or how i could change it which is the block that it says is being called for the categories in the layered navigation

class Mage_Catalog_Block_Layer_Filter_Category extends Mage_Catalog_Block_Layer_Filter_Abstract
{
    public function __construct()
    {
        parent::__construct();
        $this->_filterModelName = 'catalog/layer_filter_category';
    }
}

So i need to have 3M Littermann stethoscope to be the first category that shows up and not All categories, what will i have to change to get that happening?

Thank you


texts: How can I make certain products tax exempt for both product and shipping price?

texts:
I have read a lot of materials online about tax classes and such in Magento, but am still unable to answer this question: how can I make certain products tax exempt for both product price and shipping?

For example, product A is £25 and is tax exempt. I can easily set the tax class to apply no tax, and simply have £25 as the product price. However, whenever shipping is processed, a 20% tax will always be separated from the overall delivery price. For example, if delivery was £2, it would be processed as £1.60 + £0.40 tax.

What combination of settings do I need to use to ensure that tax-exempt products show a fixed product price and a fixed shipping price, while other products (subject to tax) separate out tax from the product price and the shipping price?

Thanks,
Andre


texts: Pull in Terms and Conditions from Static Block

texts:
On Terms and Conditions we try to pull in a static block
{{block class="Magento\Cms\Block\Block" block_id="terms_and_conditions"}}

{{block id='terms_and_conditions'}}

Both variants are displayed as code and the static block content is not resolved.
Why is this?
edit There is this module: https://github.com/UnimixPro/magento2_CheckoutAgreement
I believe it worked out of the box in earlier Magento versions.


texts: Magento 2 cannot override 3rd party controller

texts:
Im trying to override a controller from swissup/firecheckout location in my vendor folder
my di.xml is
<?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="Swissup\FieldManager\Controller\Adminhtml\Index\Save"
                type="My\Module\Controller\Adminhtml\Index\Save" />
</config>

and my controller is
namespace My\Module\Controller\Adminhtml\Index;

class Save extends \Magento\Framework\App\Action\Action
{
    public function execute()
    {
        die('sample die');
    }
}

but its still executing in Swissup\FieldManager\Controller\Adminhtml\Index\Save execute function. ive been debugging this one for quite some time now and dont know why its not working. i tried both etc/di.xml and etc/adminhtml/di.xml


texts: Magento2 - Change customer group programatically conditionally

texts:
I need to dynamically change logged in customer group ID to get products prices from another group. I tried :

$this->session->setCustomerGroupId(NEWGROUPID);

It's working great for product pages and categories pages but it does not work on checkout cart and onepage.


texts: Magento 2 How To Get Recently View Product Collection All Users

texts:
How can i configure the recently viewed products widget to show the products that all visitors recently viewed

Ref:Recently viewed products from all users

Let me know how can i do it


texts: Magento2 - How to get base url in js file added to backend?

texts:
I have try to get base url using mage/url in my custom js , but it return url without base url so,
is there any another way using that we can get magento base url in js which is added in admin side ?


texts: Table in MySQL to show product data in Magento 2 after reindexing process

texts:
I want to know about those MYSQL tables which is used to fetch data for Front-end Products in Magento 2 after re-indexing process.
Like which table will be used after re-indexing process to show products on store.
And i want also know which table will be responsible for particular reindex process.
And if any post that is explain about reindexing process it will be very helpfull.
Any help is appriciated.


texts: Magento 2 : Custom order email template customization

texts:
I want to customize the email template
I have added as per below by override two files default.phmtl and items.phtml
(I have added three addition td tags).
Below is email which I receive exactly

But the order total section is shows problematic.
can any one guide how to move this section right using CSS or any other way


texts: How to add block and template to any page without using layout xml

texts:
Please help me and give me some example this question on title.
And How does method toHtml() work?

What is method setPart() used to do?


texts: How to create new tab in add product page backend

texts:
I want to create new tab in admin panel while adding a product then assign all attribute under that tab

Like i store all custom attribute under that tab


texts: How to add Manufacturer filter in the left bar

texts:
I am learning magento 1.9.

I need to add Manufacturer filter in the left bar along with Category and Filter. I went through this link and tried same thing but it didn't work.

Even in that post, that solution is not marked as the correct one. Can anybody help me? Thank you.


texts: Add custom option image to configurable drop down

texts: I Want to Show configurable product's custom option drop down with custom option image. Can you please inform me what should I do for this ?


texts: How can I enforce the import of a product status on a product import?

texts:
I'm Importing products from another shop system to a new magento installation (1.9.0.1). Therefore I have created a CSV which gets imported via a import profile. The import process shows no errors but after the import the products don't show up in Catalog -> Manage Products. But they do show up in Catalog -> Manage Categories and they can also be edited/accessed via the url /catalog_product/edit/id/{manually enter new ID here}.

In the edit form and when exporting the products again and comparing them to correct products (which do show up and which I created regularly) I noticed, that the status attribute is missing. When I set it from "-- Please Select --" in the edit mask to "Enabled" or "Disabled" and save, the product shows up and seems to work properly.

However I have found no way, to get the import profile to import the status in the first place. I have a "status" field in my CSV and I have tried 1, "1", 2, "2", Enabled, "Enabled", Disabled and "Disabled". I have also tried to change the position of my status field but absolutely no luck. Everything else (including media links) gets imported correctly.

What am I missing or what can I do? I also wouldn't mind to bulk fix the products after the import as it is a one time import but as I cannot see them in the catalog list, I am not sure if there is a good way to do so. Or where would be the place to hook into the import process and fix this problem quick and dirty with some php lines that would just enforces that a status is set on every product import (I'm new to magento, so I'm not really sure where I should start looking).

Thanks for any tips!


texts:
I want to Product export. But I need Only data which I need.

For example, I need not "gift_message_available" attribute value. So Please tell me what I should

I have created the profile. but When I run that profile, the CSV file downloaded in var folder. So in that case, I need to FTP details.

but I want to download directly my System.


texts: How do I get Magento to always give the /catalog/product/view/id/ style url for products?

texts:
I want Magento to always generate product urls in the format:

  www.example.com/catalog/product/view/id/123/s/product-name.html

instead of the rewritten

  www.example.com/product-name.html

The reason for this is mainly so that I don't have to worry if something happens to all my rewrites, or so I can feel free to truncate and rebuild core_url_rewrite if something goes wrong and it gets too big.

I don't want to stop using rewritten urls entirely. I like them for categories. I have fewer categories, and I very rarely change the names. I hate feeling like I can't change the name of a product because it will make the core_url_rewrite table grow and mess up any backlinks I've generated if I lose my rewrites. Also, I still want my current urls to work for as long as possible along with the /product/view/id urls.

Is there an easy way to do this without rewriting methods that I'm missing?

Or do I have to override some getProductUrl method? It looks like the answer lies in the getProductUrl() method in Mage_Catalog_Model_Product? That class seems to use the getProductUrl() method in Mage_Catalog_Model_Product_Url.

But again, if there's some simple configuration setting that would do the trick, I'd rather do that.

Edit:
I haven't had a chance to dig through this yet, but on a related matter while working on something else, I accidentally found that there is something called getCategoryIdUrl() that does for categories what I want to done for products. I searched for the obvious getProductIdUrl and came up with nothing.

Edit:

The accepted answer given by fschmengler works really well and answers the question. But it turns out that the urls for the sitemap aren't generated with the getProductUrl() method. The sitemap is made in Mage_Sitemap_Model_Sitemap by the generateXml() method.

/**
 * Generate categories sitemap
 */
$changefreq = (string)Mage::getStoreConfig('sitemap/category/changefreq', $storeId);
$priority   = (string)Mage::getStoreConfig('sitemap/category/priority', $storeId);
$collection = Mage::getResourceModel('sitemap/catalog_category')->getCollection($storeId);
foreach ($collection as $item) {
    $xml = sprintf(
        '<url><loc>%s</loc><lastmod>%s</lastmod><changefreq>%s</changefreq><priority>%.1f</priority></url>',
        htmlspecialchars($baseUrl . $item->getUrl()),
        $date,
        $changefreq,
        $priority
    );
    $io->streamWrite($xml);
}
unset($collection);

I overrode it with something like this:

/**
 * Generate products sitemap
 */
$changefreq = (string)Mage::getStoreConfig('sitemap/product/changefreq', $storeId);
$priority   = (string)Mage::getStoreConfig('sitemap/product/priority', $storeId);
//$collection = Mage::getResourceModel('sitemap/catalog_product')->getCollection($storeId);

$rootCatId = Mage::app()->getStore($storeId)->getRootCategoryId();
$product_collection = Mage::getModel('catalog/category')->load($rootCatId)->getProductCollection()->setStoreId($storeId);
//Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($product_collection);
$product_collection->addFieldToFilter('visibility', Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)
->addAttributeToFilter('status',Mage_Catalog_Model_Product_Status::STATUS_ENABLED)
->addAttributeToSelect('url_key')
;

foreach ($product_collection as $item) {
    $url = $baseUrl.'catalog/product/view/id/'.$item->getId().'/s/'.$item->getData('url_key').'/';
    $xml = sprintf(
        '<url><loc>%s</loc><lastmod>%s</lastmod><changefreq>%s</changefreq><priority>%.1f</priority></url>',
        htmlspecialchars($url),
        $date,
        $changefreq,
        $priority
    );
    $io->streamWrite($xml);
}

//unset($collection);

It's not the most elegant solution, but it seems to work so far.


texts: Magento 2.2.2 Upgrade to 2.2.6 Not Latest

texts:
I want to upgrade a magento 2.2.2 site to 2.2.6 mainly to fix issues with very slow reindex esp for Catalog Search index when Elasticsearch is being used

I dont want to upgrade to the latest 2.3.2 version as there a alot of issues with various extensions

Please can someone let me know how this can be done with the little amount of fuss - Thank You


texts: Magento2: Export grid data in xls format

texts:
I have created a grid using UI componet, I want to export grid data in .xls file.
How can I do this, please advice me.


texts: Schedule CMS block content change on a specific date

texts:
We have a CMS block on our front page and we would like to automatically change the content of it on Black Friday, for example.

How could we do this?


texts: Use custom mail address when sending transaction mails?

texts:
Magento 1.9
This is my code:
$mailTemplate->setDesignConfig(array('area' => 'frontend'))
                    ->setReplyTo($post['email'])
                    ->sendTransactional(
                        Mage::getStoreConfig(self::XML_PATH_EMAIL_TEMPLATE),
                        Mage::getStoreConfig(self::XML_PATH_EMAIL_SENDER),
                        Mage::getStoreConfig(self::XML_PATH_EMAIL_RECIPIENT),
                        null,
                        array('data' => $postObject)
                    );

I want to set a custom sender so I tried to replace this line
Mage::getStoreConfig(self::XML_PATH_EMAIL_SENDER)

with something like
'test@example.com'

Does not work! Any idea how to make this work?
Thanks


texts: paypal check shipping address instead of billing

texts:
In our shop we have set specific countries for our Paypal Express, fx we don't allow this billing option for Vietnam.
Now we see some customers making orders by setting an American billing address and shipping to Vietnam.

How do we make the system check the shipping address instead of the billing address?


texts: Error while uploading site from local to live server

texts:
I have uploaded the quick-start package of theme sm-g3shop in my localhost , it was working fine showing exactly the demo website but when i have uploaded that website on  live server from localhost it show only html type of data. All the elements of theme are disrupted and its not showing as expected.
please help me to solve this error


texts:
I want to detect database deadlock event in my Magento2 (2.3.2) store. Based on that I want to send email to higher authority persons to let them know about deadlock instantly.

Any help would be appreciated.

Thanks,


texts: How to redirect to cart after login using an observer in Magento 2

texts:
By default when guest checkout is disabled in Magento 2.

No matter where a user is trying to go they're forwarded to their account after login, including if they've already added items to their cart and have clicked checkout in their mini-cart.

I feel like this is a hindrance to the sales pipeline.

I'm attempting to make an observer that redirects a user to their cart/checkout if that was their intended purpose.

Even if they need to create an account in between.

Currently, I'm working on step one. Simply redirecting someone to their cart after logging in. The problem is that it seems none of the various redirect techniques have worked except for those that use exit(); or die(); in their methods.

In the notes of these suggestions, there are warnings not to use these functions as it interrupts the application.

Is there a good way to redirect a customer after they've logged in? Here is what I have so far:

=> etc/events.xml:

<?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_login">
        <observer name="made_up_name_seems_to_work" instance="Vendor\NameSpace\Observer\Redirect" />
    </event>
</config>

=> Observer/Redirect.php:

<?php

namespace Vendor\NameSpace\Observer;

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

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

    protected $_responseFactory;
    protected $_url;
    protected $_session;

    public function __construct(
        \Magento\Customer\Model\Session $session,
        \Magento\Framework\App\ResponseFactory $responseFactory,
        \Magento\Framework\UrlInterface $url
    ) {
        $this->_session = $session;
        $this->_responseFactory = $responseFactory;
        $this->_url = $url;
    }

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

        $isCustomerLoggedIn = $this->_session->isLoggedIn();

        if ($isCustomerLoggedIn) {

            $event = $observer->getEvent();
            $CustomRedirectionUrl = $this->_url->getUrl('checkout/cart');
            $this->_responseFactory->create()->setRedirect($CustomRedirectionUrl)->sendResponse();
            \Magento\Framework\App\ObjectManager::getInstance()->get('Psr\Log\LoggerInterface')->debug('URL: ' . $CustomRedirectionUrl);
            return $this;
        }
    }
}

The above redirect isn't working at all even with Exit() or die() however, it reflects where I'm at currently.

Is there a good(or proper) way to redirect from this observer?


texts:
Getting fatal error on Item (Mage_Catalog_Model_Product) with the same id "223" already exist

Here 223 is my product Id

My _prepareCollection() Method

protected function _prepareCollection()
{
    $coll = Mage::getModel('catalog/product')->getCollection()
                ->addAttributeToFilter('name',array('neq'=>''))
                ->addAttributeToFilter('attribute_code',$this->getRequest()->getParam('my_value'));

    $coll->getSelect()->join( array('order_item'=> 'mgnt_sales_flat_order_item'), 'order_item.product_id = e.entity_id', array('order_item.created_at as ocreated','order_item.qty_ordered as sales_units', 'order_item.row_total as sales_total' , 'order_item.discount_amount as discount', 'order_item.item_id as item_id' ) );
    $coll->getSelect()->join( array('order'=> 'mgnt_sales_flat_order'), 'order.entity_id = order_item.order_id', array('customer_name'=>'order.customer_firstname'));

     $this->setCollection($coll);

    // echo $coll->getSelect();

     return parent::_prepareCollection();
}

My _prepareColumns() method

protected function _prepareColumns()
{

    $this->addColumn('entity_id', array(
        'header' => $this->_getHelper()->__('entity_id'),
        'type' => 'text',
        'index' => 'entity_id',
        'filter'    => false,
        'sortable'  => false
    ));
    $this->addColumn('name', array(
        'header' => $this->_getHelper()->__('Product Name'),
        'type' => 'text',
        'index' => 'name',
        'filter'    => false,
        'sortable'  => false
    ));

    $this->addColumn('customer_name', array(
        'header' => $this->_getHelper()->__('customer_name'),
        'type' => 'number',
        'index' => 'customer_name',
        'filter'    => false,
        'sortable'  => false
    ));
    $this->addColumn('sales_total', array(
        'header' => $this->_getHelper()->__('Sales Total'),
        'type' => 'number',
        'index' => 'sales_total',
        'filter'    => false,
        'sortable'  => false
    ));
    $this->addColumn('discount', array(
        'header' => $this->_getHelper()->__('Discount'),
        'type' => 'number',
        'index' => 'discount',
        'filter'    => false,
        'sortable'  => false
    ));

    return parent::_prepareColumns();

}


texts: How to change default file log name in Magento 2 in Psr Logger?

texts:
I have an instance of a logger in my PHP script that I use. I instantiate it like this:

$logger = $om->get("Psr\Log\LoggerInterface");

I can log text like this:

$logger->debug("caruk");

but it is always logged in the file var/log/debug.log . I want to log error messages in my own custom file customfile.log . How can I do this?


texts:
I want to add a button only on those products which are having product size.Button displaying over Color attribute.

My XML file is catalog_product_view.xml

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

<body>
    <referenceBlock name="product.info.main">
        <block class="VENDOR\MODULE\Block\Button" name="myButton" template="VENDOR_MODULE::button.phtml" />
    </referenceBlock>
</body>
</page>

Right now it is displaying on all products.
Thanks in Advance


texts: Overriding model file is not working in Magento 2.2.5

texts:
I tried to override model, but it is not working. I need to override:

  Magento\Catalog\Model\Product\Attribute\Backend\Price to
  Pawan\Catalog\Model\Rewrite\Product\Attribute\Backend\Price

But it not working.

My di.xml path Pawan/Catalog/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\Catalog\Model\Product\Attribute\Backend\Price" typr="Pawan\Catalog\Model\Rewrite\Product\Attribute\Backend\Price" />
  </config>

My model file:

<?php
    namespace Pawan\Catalog\Model\Rewrite\Product\Attribute\Backend;

    class Price extends \Magento\Catalog\Model\Product\Attribute\Backend\Price
    {
        public function afterSave($object)
        {
            $writer = new \Zend\Log\Writer\Stream(BP . '/var/log/importmissingorders.log');
            $logger = new \Zend\Log\Logger();
            $logger->addWriter($writer);
            $logger->info("custom model");

            /** @var $attribute \Magento\Catalog\Model\ResourceModel\Eav\Attribute */
            $attribute = $this->getAttribute();
            $attributeCode = $attribute->getAttributeCode();
            $value = $object->getData($attributeCode);

            // $value may be passed as null to unset the attribute
            if ($value === null || (float)$value > 0) {
                if ($attribute->isScopeWebsite() && $object->getStoreId() != \Magento\Store\Model\Store::DEFAULT_STORE_ID) {
                    if ($this->isUseDefault($object)) {
                        $value = null;
                    }
                    foreach ((array)$object->getWebsiteStoreIds() as $storeId) {
                        $object->addAttributeUpdate($attributeCode, $value, $storeId);
                    }
                }
            }
            return $this;
        }
    }

It is still executing the core file only.

What am I doing wrong?


texts: How to exclude a specific categories from tax calculation?

texts:
In my country there's a specific items that doesn't have Tax on it. How to exclude these products categories from calculating tax on them in Magento 2.3.2

Regards.


texts: Magento 2 Commerce cloud database export

texts:
I am new in magento commerce cloud. I need to setup the magento store in my local system. I have downloaded the files from the commerce git and it is working fine. But how can I access the database? I need to import the database to my local system. I have created the database backup using the below command.

  vendor/bin/ece-tools db-dump

How can I download it in to my local system? Please help me


texts: Magento 2: How to Create "home" link in category

texts:
My Magento version is 2.3, I want to create "home" and "about" link in the category, I search few articles but it is for Magento 2.0 version, I was not able to find for Magento 2.3 version. I want first Home, About then categories.

https://www.marketplace.jawadditaksal.org/


texts: How to remove particular coupon code if other cart rule without specific coupon is applied on product in magento2?

texts:
condition 1: I have 2 cart rule which are directly applied on product if specific conditions are true as given in cart rule.

condition 2: there is an another cart rule in which i have added one coupon code "10OFF" for all products.

Question is that if for particular product one cart rule is already applied then i want to remove coupon code
because same time two discount is applied based on condition 1 and condition 2 ,

so how can i remove coupon code if there is already discount is applied by other cart rule ,
please any one have an idea about this let me know. Thanks in advance.


texts: Configurable Product created with existing SKUs won't let users add to cart?

texts:
For background, I had 16 existing SKUs that were essentially the same product but in different sizes (Industrial burs, with different sized heads). They all have their own individual product pages, and it was a really cluttered, overwhelming customer experience.

To remedy, I went to Products> Catalog> Add Configurable Product and created a new product with same naming convention as the 16 existing SKUs, just leaving out the size descriptions from the title. I then went into each of the 16 SKUs and added a size attribute to them. I went back to the New Configurable Product, added a dummy SKU to get the "Enter Products Manually" option to appear, then went in and added all 16 existing SKUs to the configuration and removed the dummy SKU.

The issue I'm having is that when I'm on the configurable product page, I have the option to select any of my sizes as was my goal, BUT I can't add anything to my cart. I'm met with a "Request Pricing" Button instead (which we use intentionally for other products on the site, but not for any of the 16 SKUs that were variated). I should also mention that we have advanced pricing set up for these 16 SKUs where the price would decrease as a higher quantity was ordered- this option is not showing up either in the configurable page. I am unsure if that is what's causing the Request pricing issue or not, but it's also another issue we need help with as those price breaks are important to keep.

I also noticed that now when I search the products, all 16 SKUs do still pop up individually with their own product pages plus the new configuarble product, so there's a total of 17 options instead of the desired 1, defeating the purpose of cleaning up the overwhelming search results.

I am hoping somebody can tell me how to fix these issues!
We are using Magento version 2.1.7


texts:
Working on a site that has multiple stores and their own homepages. Im trying to update all of these homepages with new data via a data-upgrade script.

Here what i have so far:

 $stores = Mage::app()->getStores();

foreach ($stores as $store){
    Mage::app()->setCurrentStore($store->getStoreId());
    $page = Mage::getModel('cms/page')->load('homepage-2012');
    $page_content = file_get_contents(__DIR__ . '/markup-0.0.2/homepage/content.html');
    $page->setContent($page_content)
        ->setRootTemplate('one_column_notcontained')
        ->save();
}
unset($page_content,$page,$stores);

The problem is the pages content and root template aren't updating on the stores.

I have used breakpoints to check the store ids are correct and the loop is working as it should and it seems to be doing what it should -> getting the store id, setting that store id as currentStore being used and then loading the cms homepage related to that store is and using the identifier set.

Any ideas why this might not be working?

Cheers


texts: While import product custom options throws error in magento 2

texts:
While trying to import custom options for product throws the below error. Please provide me a solution

  SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry
  '4953' for key 'PRIMARY', query was: INSERT INTO
  catalog_product_option_type_value
  (option_type_id,sort_order,sku,option_id) VALUES (?, ?, ?, ?),
  (?, ?, ?, ?), (?,


texts:
I upgraded (luckily) my testserver to 2.3.4 (from 2.3.3) and i can't view the full order information anymore. Also mail is not send when i want to send an invoice.

Strange thing is that i also upgraded an other server with almost the same configuration and there is no problem...

system.log:

main.CRITICAL: Notice: Undefined offset: 1 in vendor/magento/framework/Filter/DirectiveProcessor/IfDirective.php on line 43

exception.log

main.CRITICAL: Notice: Undefined offset: 1 in vendor/magento/framework/Filter/DirectiveProcessor/IfDirective.php on line 43 {"exception":"[object] (Exception(code: 0): Notice: Undefined offset: 1 in vendor/magento/framework/Filter/DirectiveProcessor/IfDirective.php on line 43 at vendor/magento/framework/App/ErrorHandler.php:61)"} []


texts: Allowed memory size of 792723456 issue on Magento 2.3.4

texts:
I am receiving a memory issue since I upgrated magento from 2.3.3 to 2.3.4. This is the exact message:

PHP Fatal error:  Allowed memory size of 792723456 bytes exhausted (tried to allocate 20480 bytes)

in /path/to/magentofolder/vendor/magento/module-config/App/Config/Type/System.php on line 180

Increasing the memory limit will not fix the issue :( . So i started to debug this. I went to this method: \Magento\Config\App\Config\Type\System::getWithParts and I added a log file:

private function getWithParts($path)
{
//my log debug code:
    $writer = new \Zend\Log\Writer\Stream(BP . '/var/log/test.log');
    $logger = new \Zend\Log\Logger();
    $logger->addWriter($writer);
    $logger->info(print_r($path, true));

    $pathParts = explode('/', $path);

    if (count($pathParts) === 1 && $pathParts[0] !== ScopeInterface::SCOPE_DEFAULT) {
        if (!isset($this->data[$pathParts[0]])) {
            $data = $this->readData();
            $this->data = array_replace_recursive($data, $this->data);
        }

        return $this->data[$pathParts[0]];
    }

    $scopeType = array_shift($pathParts);

    if ($scopeType === ScopeInterface::SCOPE_DEFAULT) {
        if (!isset($this->data[$scopeType])) {
            $this->data = array_replace_recursive($this->loadDefaultScopeData($scopeType), $this->data);
        }

        return $this->getDataByPathParts($this->data[$scopeType], $pathParts);
    }

    $scopeId = array_shift($pathParts);

    if (!isset($this->data[$scopeType][$scopeId])) {
        $scopeData = $this->loadScopeData($scopeType, $scopeId);

        if (!isset($this->data[$scopeType][$scopeId])) {
            $this->data = array_replace_recursive($scopeData, $this->data);
        }
    }

    return isset($this->data[$scopeType][$scopeId])
        ? $this->getDataByPathParts($this->data[$scopeType][$scopeId], $pathParts)
        : null;
}

What i noticed that after getting all of the paths, it kept stuck at: stores/default/general/locale/timezone and it keeps adding the stores/default/general/locale/timezone in my log file forever. Looks like an infinite loop or something, but not sure what triggers it . Any idea how debug this ? or did you face similar issue ?

Thank you


texts: How can I get special price of an ordered product in "sales_flat_order_item" table

texts:
A product which have following prices in catalog has been sold with qty 1:-

Price - 65.00 [INR] [Inc. Tax Rs 8.23]
Rate -  51.61 [INR] [Inc. Tax Rs 6.54]
SpecialPrice - 61.75 [INR] [Inc. Tax Rs 7.82]
Cost  - 59.09

when I go to table "sales_flat_order_item" and find this item, there following prices are being shown-

base_cost - 59.09
price - 53.93
base_price - 53.93
original_price - 61.75
base_original_price - 61.75
tax_percent - 14.5
tax_amount - 7.82

Now in this table which column represent Rate, Special Price and Price of product? So I can know what was the selling price of this product.


texts: Magento 1.9.1.1 cron.php High Resource Usage?

texts:
I an operating Magento 1.9.1.1 on Arvixe. A few days after upgrading to 1.9.1.1 from 1.9.1.0, I get an email from Arvixe stating:

  Your account is causing high load on the shared server , It is running
  processes that are consuming high CPU values and for extended periods
  of time. We had no choice but to disable web accesss for the following
  script:

  --  /home/USER/public_html/cron.php

  Please have a look at currently running processes for your account and
  their resource consumption:

  lbingman shademountainarmory.com 77.80 0.02 3.8 Top Process %CPU 41.0
  /usr/bin/php /home/lbingman/public_html/cron.php Top Process %CPU 32.0
  /usr/bin/php /home/lbingman/public_html/cron.php -mdefault Top Process
  %CPU 31.0 /usr/bin/php /home/lbingman/public_html/cron.php -malways

Is this something with a newer cron.php file that is hogging resources? If I restore my backup from 1.9.1.0, would that potentially fix this issue?

Basically, because of the script being disabled by the hosting provider, I can get no emails nor send any emails. I'd really like a solution to this as fast as possible.